From 61a382f7fab833783700d30b4f8d924a1e112281 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 13 Mar 2023 19:11:32 -0700 Subject: [PATCH 1/5] src/sage/categories/rings.py: Do not fail if RingDerivation cannot be imported for an isinstance test --- src/sage/categories/rings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sage/categories/rings.py b/src/sage/categories/rings.py index 6a7589bb109..50dba914250 100644 --- a/src/sage/categories/rings.py +++ b/src/sage/categories/rings.py @@ -1159,7 +1159,10 @@ def normalize_arg(arg): if isinstance(arg, tuple): from sage.categories.morphism import Morphism - from sage.rings.derivation import RingDerivation + try: + from sage.rings.derivation import RingDerivation + except ImportError: + RingDerivation = () if len(arg) == 2 and isinstance(arg[1], (Morphism, RingDerivation)): from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing return OrePolynomialRing(self, arg[1], names=arg[0]) From 398c6e0e1f8aeef12946d0dfd14f1fc16f50b35a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 2 Mar 2023 16:47:38 -0800 Subject: [PATCH 2/5] src/sage/categories/finite_dimensional_lie_algebras_with_basis.py: Move imports from sage.algebras, sage.matrix into methods --- ...ite_dimensional_lie_algebras_with_basis.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py b/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py index bfe0de224b2..487924b5748 100644 --- a/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py +++ b/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py @@ -24,9 +24,7 @@ from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring from sage.categories.lie_algebras import LieAlgebras from sage.categories.subobjects import SubobjectsCategory -from sage.algebras.free_algebra import FreeAlgebra from sage.sets.family import Family -from sage.matrix.constructor import matrix class FiniteDimensionalLieAlgebrasWithBasis(CategoryWithAxiom_over_base_ring): @@ -97,6 +95,8 @@ def _construct_UEA(self): The 6-Witt Lie algebra over Ring of integers modulo 6 in the Poincare-Birkhoff-Witt basis """ + from sage.algebras.free_algebra import FreeAlgebra + # Create the UEA relations # We need to get names for the basis elements, not just the generators I = self._basis_ordering @@ -321,6 +321,8 @@ def killing_form_matrix(self): sage: parent(m) Full MatrixSpace of 0 by 0 dense matrices over Rational Field """ + from sage.matrix.constructor import matrix + B = self.basis() m = matrix(self.base_ring(), [[self.killing_form(x, y) for x in B] for y in B]) @@ -420,6 +422,8 @@ def centralizer_basis(self, S): D{1} + D{1, 2} + D{2, 3} + D{3}, D{1, 2, 3} + D{1, 3} + D{2}) """ + from sage.matrix.constructor import matrix + #from sage.algebras.lie_algebras.subalgebra import LieSubalgebra #if isinstance(S, LieSubalgebra) or S is self: if S is self: @@ -541,6 +545,7 @@ def derivations_basis(self): :wikipedia:`Derivation_(differential_algebra)` """ from sage.matrix.constructor import matrix + R = self.base_ring() B = self.basis() keys = list(B.keys()) @@ -581,6 +586,8 @@ def inner_derivations_basis(self): [1 0 0], [0 1 0] ) """ + from sage.matrix.constructor import matrix + R = self.base_ring() IDer = matrix(R, [b.adjoint_matrix().list() for b in self.basis()]) N = self.dimension() @@ -691,6 +698,9 @@ def is_ideal(self, A): if A not in LieAlgebras(self.base_ring()).FiniteDimensional().WithBasis(): raise NotImplementedError("A must be a finite dimensional" " Lie algebra with basis") + + from sage.matrix.constructor import matrix + B = self.basis() AB = A.basis() try: @@ -798,6 +808,8 @@ def product_space(self, L, submodule=False): Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis: () """ + from sage.matrix.constructor import matrix + # Make sure we lift everything to the ambient space if self in LieAlgebras(self.base_ring()).Subobjects(): A = self.ambient() @@ -1373,6 +1385,8 @@ def as_finite_dimensional_algebra(self): sage: X * Y Z """ + from sage.matrix.constructor import matrix + K = self._basis_ordering mats = [] R = self.base_ring() @@ -1606,6 +1620,8 @@ def adjoint_matrix(self, sparse=False): # In #11111 (more or less) by using matr sage: E1 * E2 - E2 * E1 == e12.adjoint_matrix() True """ + from sage.matrix.constructor import matrix + P = self.parent() basis = P.basis() return matrix(self.base_ring(), From f38d5ee5ee02a436a640bb9e4720c67fada3b33c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 Mar 2023 00:12:30 -0800 Subject: [PATCH 3/5] sage.categories: Fix imports --- src/sage/categories/pushout.py | 4 ++-- src/sage/groups/all__sagemath_objects.py | 0 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 src/sage/groups/all__sagemath_objects.py diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py index 6c5b08e003a..467715426d9 100644 --- a/src/sage/categories/pushout.py +++ b/src/sage/categories/pushout.py @@ -3462,8 +3462,8 @@ def merge(self, other): # nothing else helps, hence, we move to the pushout of the codomains of the embeddings try: P = pushout(self.embeddings[0].parent(), other.embeddings[0].parent()) - from sage.rings.number_field.number_field import is_NumberField - if is_NumberField(P): + from sage.rings.number_field.number_field_base import NumberField + if isinstance(p, NumberField): return P.construction()[0] except CoercionException: return None diff --git a/src/sage/groups/all__sagemath_objects.py b/src/sage/groups/all__sagemath_objects.py new file mode 100644 index 00000000000..e69de29bb2d From df0507d2cdaffe64e83bce8e32121bc8c6d05d57 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 13 Mar 2023 19:31:16 -0700 Subject: [PATCH 4/5] sage.categories: Move some imports into methods --- src/sage/categories/finite_complex_reflection_groups.py | 3 ++- src/sage/categories/loop_crystals.py | 9 +++++++-- src/sage/groups/all__sagemath_objects.py | 0 3 files changed, 9 insertions(+), 3 deletions(-) delete mode 100644 src/sage/groups/all__sagemath_objects.py diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py index f1897267140..83db9835f51 100644 --- a/src/sage/categories/finite_complex_reflection_groups.py +++ b/src/sage/categories/finite_complex_reflection_groups.py @@ -16,7 +16,6 @@ from sage.misc.cachefunc import cached_method from sage.categories.category_with_axiom import CategoryWithAxiom from sage.categories.coxeter_groups import CoxeterGroups -from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet class FiniteComplexReflectionGroups(CategoryWithAxiom): @@ -758,6 +757,8 @@ def absolute_order_ideal(self, gens=None, [1] 1 [] 0 """ + from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet + if gens is None: seeds = [(self.coxeter_element(), self.rank())] else: diff --git a/src/sage/categories/loop_crystals.py b/src/sage/categories/loop_crystals.py index e065b7ef4f6..415d8c308f7 100644 --- a/src/sage/categories/loop_crystals.py +++ b/src/sage/categories/loop_crystals.py @@ -19,8 +19,7 @@ from sage.categories.regular_crystals import RegularCrystals from sage.categories.tensor import TensorProductsCategory from sage.categories.map import Map -from sage.graphs.dot2tex_utils import have_dot2tex -from sage.functions.other import ceil + class LoopCrystals(Category_singleton): r""" @@ -117,6 +116,8 @@ def digraph(self, subset=None, index_set=None): {...'edge_options': ...} sage: view(G, tightpage=True) # optional - dot2tex graphviz, not tested (opens external window) """ + from sage.graphs.dot2tex_utils import have_dot2tex + G = Crystals().parent_class.digraph(self, subset, index_set) if have_dot2tex(): def eopt(u_v_label): @@ -959,6 +960,8 @@ def energy_function(self, algorithm=None): ....: for b in hw) True """ + from sage.functions.other import ceil + C = self.parent().crystals[0] ell = ceil(C.s()/C.cartan_type().c()[C.r()]) is_perfect = all(ell == K.s()/K.cartan_type().c()[K.r()] @@ -1090,6 +1093,8 @@ def e_string_to_ground_state(self): ....: for elt in hw) True """ + from sage.functions.other import ceil + ell = max(ceil(K.s()/K.cartan_type().c()[K.r()]) for K in self.parent().crystals) if self.cartan_type().dual().type() == 'BC': diff --git a/src/sage/groups/all__sagemath_objects.py b/src/sage/groups/all__sagemath_objects.py deleted file mode 100644 index e69de29bb2d..00000000000 From 87224620e3ce0beb3dcf48f374d7a2e0f8a04f01 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 13 Mar 2023 23:34:13 -0700 Subject: [PATCH 5/5] src/sage/categories/pushout.py: Fix up number field test --- src/sage/categories/pushout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py index 467715426d9..cbeb1f30cb0 100644 --- a/src/sage/categories/pushout.py +++ b/src/sage/categories/pushout.py @@ -3463,7 +3463,7 @@ def merge(self, other): try: P = pushout(self.embeddings[0].parent(), other.embeddings[0].parent()) from sage.rings.number_field.number_field_base import NumberField - if isinstance(p, NumberField): + if isinstance(P, NumberField): return P.construction()[0] except CoercionException: return None