Skip to content

Commit

Permalink
Merge branch 'rel_import_modules' into meson-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez authored Oct 30, 2023
2 parents 3840207 + 6260d14 commit 781f001
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 72 deletions.
33 changes: 20 additions & 13 deletions src/sage/modules/all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#*****************************************************************************
# *****************************************************************************
# Copyright (C) 2005 William Stein <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
Expand All @@ -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")
2 changes: 1 addition & 1 deletion src/sage/modules/complex_double_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
70 changes: 45 additions & 25 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

###############################################################################
#
Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()))

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions src/sage/modules/free_module_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modules/free_quadratic_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

# #############################################################################
#
Expand Down Expand Up @@ -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():
Expand Down
9 changes: 5 additions & 4 deletions src/sage/modules/quotient_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

###############################################################################
#
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/real_double_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 6 additions & 4 deletions src/sage/modules/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_callable_symbolic_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_complex_double_dense.pxd
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/sage/modules/vector_double_dense.pxd
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/sage/modules/vector_integer_dense.pxd
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_mod2_dense.pxd
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_modn_dense.pxd
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_numpy_dense.pxd
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_numpy_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_numpy_integer_dense.pxd
Original file line number Diff line number Diff line change
@@ -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):

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_rational_dense.pxd
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_real_double_dense.pxd
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 8 additions & 5 deletions src/sage/modules/vector_space_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = ()

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/vector_symbolic_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading

0 comments on commit 781f001

Please sign in to comment.