diff --git a/src/sage/modules/all.py b/src/sage/modules/all.py index 87621e61b29..660f1ef3807 100644 --- a/src/sage/modules/all.py +++ b/src/sage/modules/all.py @@ -1,4 +1,4 @@ -#***************************************************************************** +# ***************************************************************************** # Copyright (C) 2005 William Stein # # Distributed under the terms of the GNU General Public License (GPL) @@ -11,23 +11,30 @@ # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ -#***************************************************************************** +# ***************************************************************************** -from .free_module import FreeModule, VectorSpace, span +from sage.modules.free_module import FreeModule, VectorSpace, span -from .free_quadratic_module import (FreeQuadraticModule, QuadraticSpace, - InnerProductSpace) +from sage.modules.free_quadratic_module import ( + FreeQuadraticModule, + QuadraticSpace, + InnerProductSpace, +) -from .free_module_element import (vector, free_module_element, zero_vector, - random_vector) +from sage.modules.free_module_element import ( + vector, + free_module_element, + zero_vector, + random_vector, +) -from .vector_space_morphism import linear_transformation +from sage.modules.vector_space_morphism import linear_transformation -from .with_basis.all import * +from sage.modules.with_basis.all import * from sage.misc.lazy_import import lazy_import -lazy_import('sage.modules.filtered_vector_space', 'FilteredVectorSpace') -lazy_import('sage.modules.multi_filtered_vector_space', 'MultiFilteredVectorSpace') -lazy_import('sage.modules.free_quadratic_module_integer_symmetric', 'IntegralLattice') -lazy_import('sage.modules.torsion_quadratic_module', 'TorsionQuadraticForm') +lazy_import("sage.modules.filtered_vector_space", "FilteredVectorSpace") +lazy_import("sage.modules.multi_filtered_vector_space", "MultiFilteredVectorSpace") +lazy_import("sage.modules.free_quadratic_module_integer_symmetric", "IntegralLattice") +lazy_import("sage.modules.torsion_quadratic_module", "TorsionQuadraticForm") diff --git a/src/sage/modules/complex_double_vector.py b/src/sage/modules/complex_double_vector.py index 88ad6bb6d67..728d862e8fc 100644 --- a/src/sage/modules/complex_double_vector.py +++ b/src/sage/modules/complex_double_vector.py @@ -19,6 +19,6 @@ # http://www.gnu.org/licenses/ ############################################################################### -from .vector_complex_double_dense import Vector_complex_double_dense +from sage.modules.vector_complex_double_dense import Vector_complex_double_dense ComplexDoubleVectorSpaceElement = Vector_complex_double_dense diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index 8f584a211ef..cadae277429 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -177,33 +177,41 @@ ########################################################################### import itertools +from warnings import warn -from . import free_module_element import sage.matrix.matrix_space import sage.misc.latex as latex - -from sage.modules.module import Module -import sage.rings.ring as ring import sage.rings.abc -import sage.rings.integer_ring -import sage.rings.rational_field import sage.rings.infinity import sage.rings.integer -from sage.categories.principal_ideal_domains import PrincipalIdealDomains -from sage.categories.integral_domains import IntegralDomains +import sage.rings.integer_ring +import sage.rings.rational_field +import sage.rings.ring as ring from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets +from sage.categories.integral_domains import IntegralDomains +from sage.categories.principal_ideal_domains import PrincipalIdealDomains +from sage.misc.cachefunc import cached_method from sage.misc.lazy_attribute import lazy_attribute +from sage.misc.lazy_import import LazyImport from sage.misc.randstate import current_randstate +from sage.modules import free_module_element +from sage.modules.module import Module from sage.rings.finite_rings.finite_field_base import FiniteField from sage.structure.factory import UniqueFactory +from sage.structure.richcmp import ( + op_EQ, + op_GE, + op_GT, + op_LE, + op_LT, + op_NE, + revop, + rich_to_bool, + richcmp, + richcmp_method, + richcmp_not_equal, +) from sage.structure.sequence import Sequence -from sage.structure.richcmp import (richcmp_method, rich_to_bool, richcmp, - richcmp_not_equal, revop, - op_LT,op_LE,op_EQ,op_NE,op_GT,op_GE) -from sage.misc.cachefunc import cached_method -from sage.misc.lazy_import import LazyImport - -from warnings import warn ############################################################################### # @@ -226,7 +234,7 @@ def create_key(self, base_ring, rank, sparse=False, inner_product_matrix=None): """ rank = int(sage.rings.integer.Integer(rank)) - if not (inner_product_matrix is None): + if inner_product_matrix is not None: inner_product_matrix = sage.matrix.matrix_space.MatrixSpace(base_ring, rank)(inner_product_matrix) inner_product_matrix.set_immutable() @@ -1821,7 +1829,9 @@ def free_resolution(self, *args, **kwds): [ z x*z] 0 <-- C_0 <-------------- C_1 <-- 0 """ - from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular + from sage.rings.polynomial.multi_polynomial_libsingular import ( + MPolynomialRing_libsingular, + ) if isinstance(self.base_ring(), MPolynomialRing_libsingular): from sage.homology.free_resolution import FiniteFreeResolution_singular return FiniteFreeResolution_singular(self, *args, **kwds) @@ -1854,13 +1864,19 @@ def graded_free_resolution(self, *args, **kwds): sage: N.graded_free_resolution(degrees=[2, 1, 3], shifts=[2, 3]) # needs sage.libs.singular S(-2)⊕S(-3) <-- S(-6)⊕S(-8) <-- 0 """ - from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular + from sage.rings.polynomial.multi_polynomial_libsingular import ( + MPolynomialRing_libsingular, + ) if isinstance(self.base_ring(), MPolynomialRing_libsingular): - from sage.homology.graded_resolution import GradedFiniteFreeResolution_singular + from sage.homology.graded_resolution import ( + GradedFiniteFreeResolution_singular, + ) return GradedFiniteFreeResolution_singular(self, *args, **kwds) if isinstance(self, FreeModule_generic): - from sage.homology.graded_resolution import GradedFiniteFreeResolution_free_module + from sage.homology.graded_resolution import ( + GradedFiniteFreeResolution_free_module, + ) return GradedFiniteFreeResolution_free_module(self, *args, **kwds) raise NotImplementedError("the module must be a free module or " @@ -4084,7 +4100,9 @@ def span_of_basis(self, basis, base_ring=None, check=True, already_echelonized=F if base_ring is None or base_ring == self.base_ring(): try: if self.is_dense(): - from .free_module_integer import FreeModule_submodule_with_basis_integer + from .free_module_integer import ( + FreeModule_submodule_with_basis_integer, + ) return FreeModule_submodule_with_basis_integer(self.ambient_module(), basis=basis, check=check, already_echelonized=already_echelonized, @@ -5370,8 +5388,8 @@ def _coerce_map_from_(self, M): sage: V = QQ^2 sage: V.coerce_map_from(M) """ - from sage.modules.submodule import Submodule_free_ambient from sage.modules.quotient_module import FreeModule_ambient_field_quotient + from sage.modules.submodule import Submodule_free_ambient if isinstance(M, FreeModule_ambient_field_quotient): # No forgetful map. @@ -5989,8 +6007,8 @@ def _sympy_(self): sage: (1, 2, 3) in sZZ3 # needs sympy True """ - from sympy import ProductSet from sage.interfaces.sympy import sympy_init + from sympy import ProductSet sympy_init() return ProductSet(*([self.coordinate_ring()] * self.rank())) @@ -8194,7 +8212,7 @@ def element_class(R, is_sparse): else: return Vector_mod2_dense try: - from .vector_modn_dense import Vector_modn_dense, MAX_MODULUS + from .vector_modn_dense import MAX_MODULUS, Vector_modn_dense except ImportError: pass else: @@ -8210,7 +8228,9 @@ def element_class(R, is_sparse): return Vector_real_double_dense elif isinstance(R, sage.rings.abc.ComplexDoubleField) and not is_sparse: try: - from sage.modules.vector_complex_double_dense import Vector_complex_double_dense + from sage.modules.vector_complex_double_dense import ( + Vector_complex_double_dense, + ) except ImportError: pass else: diff --git a/src/sage/modules/free_module_morphism.py b/src/sage/modules/free_module_morphism.py index cdc933f23d0..6cf1add1f75 100644 --- a/src/sage/modules/free_module_morphism.py +++ b/src/sage/modules/free_module_morphism.py @@ -41,12 +41,10 @@ # be coercible into vector space of appropriate dimension. import sage.modules.free_module as free_module -from . import matrix_morphism from sage.categories.morphism import Morphism +from sage.modules import free_module_homspace, matrix_morphism +from sage.structure.richcmp import rich_to_bool, richcmp from sage.structure.sequence import Sequence -from sage.structure.richcmp import richcmp, rich_to_bool - -from . import free_module_homspace def is_FreeModuleMorphism(x): diff --git a/src/sage/modules/free_quadratic_module.py b/src/sage/modules/free_quadratic_module.py index ff112b9a5c2..df0f90a4fb6 100644 --- a/src/sage/modules/free_quadratic_module.py +++ b/src/sage/modules/free_quadratic_module.py @@ -71,7 +71,7 @@ import sage.misc.latex as latex import sage.rings.ring as ring from sage.categories.principal_ideal_domains import PrincipalIdealDomains -from . import free_module +from sage.modules import free_module # ############################################################################# # @@ -154,7 +154,7 @@ def FreeQuadraticModule(base_ring, rank, inner_product_matrix, if key in _cache: M = _cache[key]() - if not (M is None): + if M is not None: return M if not base_ring.is_commutative(): diff --git a/src/sage/modules/quotient_module.py b/src/sage/modules/quotient_module.py index c50c1d044fc..09c8b313c91 100644 --- a/src/sage/modules/quotient_module.py +++ b/src/sage/modules/quotient_module.py @@ -19,10 +19,11 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from .free_module import (Module_free_ambient, - FreeModule_ambient, - FreeModule_ambient_field) - +from sage.modules.free_module import ( + FreeModule_ambient, + FreeModule_ambient_field, + Module_free_ambient, +) ############################################################################### # diff --git a/src/sage/modules/real_double_vector.py b/src/sage/modules/real_double_vector.py index 1ceb320078e..5430e175f11 100644 --- a/src/sage/modules/real_double_vector.py +++ b/src/sage/modules/real_double_vector.py @@ -16,6 +16,6 @@ # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ ############################################################################### -from .vector_real_double_dense import Vector_real_double_dense +from sage.modules.vector_real_double_dense import Vector_real_double_dense RealDoubleVectorSpaceElement = Vector_real_double_dense diff --git a/src/sage/modules/submodule.py b/src/sage/modules/submodule.py index 3ab5a195f49..8d00d4f4553 100644 --- a/src/sage/modules/submodule.py +++ b/src/sage/modules/submodule.py @@ -34,10 +34,12 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.modules.free_module import (basis_seq, - Module_free_ambient, - FreeModule_ambient_domain) -from .quotient_module import QuotientModule_free_ambient +from sage.modules.free_module import ( + FreeModule_ambient_domain, + Module_free_ambient, + basis_seq, +) +from sage.modules.quotient_module import QuotientModule_free_ambient class Submodule_free_ambient(Module_free_ambient): diff --git a/src/sage/modules/vector_callable_symbolic_dense.py b/src/sage/modules/vector_callable_symbolic_dense.py index 1929eabcf46..70b05d98b66 100644 --- a/src/sage/modules/vector_callable_symbolic_dense.py +++ b/src/sage/modules/vector_callable_symbolic_dense.py @@ -49,7 +49,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from . import free_module_element +from sage.modules import free_module_element from sage.symbolic.ring import SR diff --git a/src/sage/modules/vector_complex_double_dense.pxd b/src/sage/modules/vector_complex_double_dense.pxd index f26526a1669..1681bad8c34 100644 --- a/src/sage/modules/vector_complex_double_dense.pxd +++ b/src/sage/modules/vector_complex_double_dense.pxd @@ -1,4 +1,4 @@ -from .vector_double_dense cimport Vector_double_dense +from sage.modules .vector_double_dense cimport Vector_double_dense cdef class Vector_complex_double_dense(Vector_double_dense): pass diff --git a/src/sage/modules/vector_double_dense.pxd b/src/sage/modules/vector_double_dense.pxd index f29b4597d15..c378db6c1d6 100644 --- a/src/sage/modules/vector_double_dense.pxd +++ b/src/sage/modules/vector_double_dense.pxd @@ -1,4 +1,4 @@ -from .vector_numpy_dense cimport Vector_numpy_dense +from sage.modules .vector_numpy_dense cimport Vector_numpy_dense cdef class Vector_double_dense(Vector_numpy_dense): pass diff --git a/src/sage/modules/vector_integer_dense.pxd b/src/sage/modules/vector_integer_dense.pxd index 6a221546b34..ebd69249b70 100644 --- a/src/sage/modules/vector_integer_dense.pxd +++ b/src/sage/modules/vector_integer_dense.pxd @@ -1,4 +1,4 @@ -from .free_module_element cimport FreeModuleElement +from sage.modules .free_module_element cimport FreeModuleElement from sage.libs.gmp.types cimport mpz_t from sage.structure.parent cimport Parent diff --git a/src/sage/modules/vector_mod2_dense.pxd b/src/sage/modules/vector_mod2_dense.pxd index a5542fe1345..06dc10fc841 100644 --- a/src/sage/modules/vector_mod2_dense.pxd +++ b/src/sage/modules/vector_mod2_dense.pxd @@ -1,4 +1,4 @@ -from .free_module_element cimport FreeModuleElement +from sage.modules .free_module_element cimport FreeModuleElement from sage.libs.m4ri cimport mzd_t diff --git a/src/sage/modules/vector_modn_dense.pxd b/src/sage/modules/vector_modn_dense.pxd index 4e0aff593fe..b3a7df6aac7 100644 --- a/src/sage/modules/vector_modn_dense.pxd +++ b/src/sage/modules/vector_modn_dense.pxd @@ -1,4 +1,4 @@ -from .free_module_element cimport FreeModuleElement +from sage.modules .free_module_element cimport FreeModuleElement from sage.ext.mod_int cimport mod_int cdef class Vector_modn_dense(FreeModuleElement): diff --git a/src/sage/modules/vector_numpy_dense.pxd b/src/sage/modules/vector_numpy_dense.pxd index b019bc8ebac..ec1bea61727 100644 --- a/src/sage/modules/vector_numpy_dense.pxd +++ b/src/sage/modules/vector_numpy_dense.pxd @@ -1,4 +1,4 @@ -from .free_module_element cimport FreeModuleElement +from sage.modules .free_module_element cimport FreeModuleElement cimport numpy cdef class Vector_numpy_dense(FreeModuleElement): diff --git a/src/sage/modules/vector_numpy_dense.pyx b/src/sage/modules/vector_numpy_dense.pyx index f0e2224b96d..8e0650aa90f 100644 --- a/src/sage/modules/vector_numpy_dense.pyx +++ b/src/sage/modules/vector_numpy_dense.pyx @@ -29,7 +29,7 @@ AUTHORS: cimport numpy import numpy -from .free_module_element import FreeModuleElement +from sage.modules .free_module_element import FreeModuleElement # This is for the NumPy C API (the PyArray... functions) to work numpy.import_array() diff --git a/src/sage/modules/vector_numpy_integer_dense.pxd b/src/sage/modules/vector_numpy_integer_dense.pxd index e39b90bbcb9..e2e3dbf8359 100644 --- a/src/sage/modules/vector_numpy_integer_dense.pxd +++ b/src/sage/modules/vector_numpy_integer_dense.pxd @@ -1,4 +1,4 @@ -from .vector_numpy_dense cimport Vector_numpy_dense +from sage.modules .vector_numpy_dense cimport Vector_numpy_dense cdef class Vector_numpy_integer_dense(Vector_numpy_dense): diff --git a/src/sage/modules/vector_rational_dense.pxd b/src/sage/modules/vector_rational_dense.pxd index 34db6f6252b..b70048c8705 100644 --- a/src/sage/modules/vector_rational_dense.pxd +++ b/src/sage/modules/vector_rational_dense.pxd @@ -1,4 +1,4 @@ -from .free_module_element cimport FreeModuleElement +from sage.modules .free_module_element cimport FreeModuleElement from sage.libs.gmp.types cimport mpq_t from sage.structure.parent cimport Parent diff --git a/src/sage/modules/vector_real_double_dense.pxd b/src/sage/modules/vector_real_double_dense.pxd index 6f75ec0c4dd..e5d4ad284b5 100644 --- a/src/sage/modules/vector_real_double_dense.pxd +++ b/src/sage/modules/vector_real_double_dense.pxd @@ -1,4 +1,4 @@ -from .vector_double_dense cimport Vector_double_dense +from sage.modules .vector_double_dense cimport Vector_double_dense cdef class Vector_real_double_dense(Vector_double_dense): pass diff --git a/src/sage/modules/vector_space_morphism.py b/src/sage/modules/vector_space_morphism.py index 2685462a74e..97c99d8da5b 100644 --- a/src/sage/modules/vector_space_morphism.py +++ b/src/sage/modules/vector_space_morphism.py @@ -329,11 +329,12 @@ #################################################################################### -import sage.modules.matrix_morphism as matrix_morphism import sage.modules.free_module_morphism as free_module_morphism -from . import vector_space_homspace +import sage.modules.matrix_morphism as matrix_morphism +from sage.modules import vector_space_homspace from sage.structure.element import is_Matrix + def linear_transformation(arg0, arg1=None, arg2=None, side='left'): r""" Create a linear transformation from a variety of possible inputs. @@ -692,12 +693,14 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'): ArithmeticError: some image of the function is not in the codomain, because element [1, 0] is not in free module """ + from sage.categories.homset import Hom from sage.matrix.constructor import matrix - from sage.modules.module import is_VectorSpace from sage.modules.free_module import VectorSpace - from sage.categories.homset import Hom + from sage.modules.module import is_VectorSpace try: - from sage.modules.vector_callable_symbolic_dense import Vector_callable_symbolic_dense + from sage.modules.vector_callable_symbolic_dense import ( + Vector_callable_symbolic_dense, + ) except ImportError: Vector_callable_symbolic_dense = () diff --git a/src/sage/modules/vector_symbolic_dense.py b/src/sage/modules/vector_symbolic_dense.py index ce134c0462e..46ea21be585 100644 --- a/src/sage/modules/vector_symbolic_dense.py +++ b/src/sage/modules/vector_symbolic_dense.py @@ -54,7 +54,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from . import free_module_element +from sage.modules import free_module_element from sage.symbolic.expression import Expression diff --git a/src/sage/modules/vector_symbolic_sparse.py b/src/sage/modules/vector_symbolic_sparse.py index 73cb41ae611..ff53995021c 100644 --- a/src/sage/modules/vector_symbolic_sparse.py +++ b/src/sage/modules/vector_symbolic_sparse.py @@ -56,7 +56,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from . import free_module_element +from sage.modules import free_module_element from sage.symbolic.expression import Expression