From a14d662aec9b9340385f0a92e7de92939e53c10c Mon Sep 17 00:00:00 2001 From: Alex Chandler Date: Sun, 29 Jan 2023 11:11:04 -0800 Subject: [PATCH 1/9] sage -fiximports src/sage/{categories,matrix,structure} --- src/sage/categories/bialgebras.py | 3 +- src/sage/categories/chain_complexes.py | 4 +- src/sage/categories/coalgebras.py | 2 +- src/sage/categories/coalgebras_with_basis.py | 4 +- .../examples/algebras_with_basis.py | 2 +- .../examples/commutative_additive_monoids.py | 2 +- .../commutative_additive_semigroups.py | 2 +- .../examples/finite_coxeter_groups.py | 2 +- .../finite_dimensional_algebras_with_basis.py | 2 +- ...ite_dimensional_lie_algebras_with_basis.py | 2 +- .../categories/examples/finite_monoids.py | 2 +- .../categories/examples/finite_weyl_groups.py | 2 +- .../examples/hopf_algebras_with_basis.py | 4 +- src/sage/categories/examples/lie_algebras.py | 2 +- src/sage/categories/examples/magmas.py | 2 +- src/sage/categories/examples/monoids.py | 2 +- src/sage/categories/examples/posets.py | 2 +- src/sage/categories/examples/semigroups.py | 2 +- .../categories/examples/semigroups_cython.pyx | 3 +- src/sage/categories/examples/sets_cat.py | 2 +- .../categories/examples/with_realizations.py | 4 +- .../finite_complex_reflection_groups.py | 4 +- ...inite_dimensional_bialgebras_with_basis.py | 2 +- ...inite_dimensional_coalgebras_with_basis.py | 2 +- src/sage/categories/graded_bialgebras.py | 2 +- .../graded_bialgebras_with_basis.py | 2 +- src/sage/categories/graded_hopf_algebras.py | 2 +- src/sage/categories/map.pyx | 2 +- src/sage/categories/monoid_algebras.py | 2 +- src/sage/categories/schemes.py | 2 +- src/sage/matrix/matrix2.pyx | 5 ++- src/sage/matrix/matrix_cdv.pyx | 2 +- src/sage/matrix/matrix_complex_ball_dense.pyx | 4 +- src/sage/matrix/matrix_cyclo_dense.pyx | 3 +- src/sage/matrix/matrix_integer_dense.pyx | 2 +- src/sage/matrix/matrix_integer_dense_hnf.py | 3 +- .../matrix/matrix_integer_dense_saturation.py | 3 +- .../matrix/matrix_modn_dense_template.pxi | 2 +- src/sage/matrix/matrix_modn_sparse.pyx | 2 +- src/sage/matrix/matrix_polynomial_dense.pyx | 44 +++++++++---------- src/sage/matrix/matrix_rational_dense.pyx | 2 +- src/sage/matrix/matrix_space.py | 3 +- src/sage/matrix/misc.pyx | 3 +- src/sage/structure/element.pyx | 4 +- src/sage/structure/set_factories_example.py | 2 +- 45 files changed, 85 insertions(+), 71 deletions(-) diff --git a/src/sage/categories/bialgebras.py b/src/sage/categories/bialgebras.py index e70914295af..441d924c964 100644 --- a/src/sage/categories/bialgebras.py +++ b/src/sage/categories/bialgebras.py @@ -10,7 +10,8 @@ # ***************************************************************************** from sage.categories.category_types import Category_over_base_ring -from sage.categories.all import Algebras, Coalgebras +from sage.categories.algebras import Algebras +from sage.categories.coalgebras import Coalgebras from sage.categories.super_modules import SuperModulesCategory from sage.misc.lazy_import import LazyImport diff --git a/src/sage/categories/chain_complexes.py b/src/sage/categories/chain_complexes.py index 531fc48e4cd..b1d8c578e60 100644 --- a/src/sage/categories/chain_complexes.py +++ b/src/sage/categories/chain_complexes.py @@ -46,7 +46,9 @@ def super_categories(self): [Category of modules over Ring of integers modulo 9] """ - from sage.categories.all import Fields, Modules, VectorSpaces + from sage.categories.fields import Fields + from sage.categories.modules import Modules + from sage.categories.vector_spaces import VectorSpaces base_ring = self.base_ring() if base_ring in Fields(): return [VectorSpaces(base_ring)] diff --git a/src/sage/categories/coalgebras.py b/src/sage/categories/coalgebras.py index 22a385d5f0d..3a7f8c6213a 100644 --- a/src/sage/categories/coalgebras.py +++ b/src/sage/categories/coalgebras.py @@ -10,7 +10,7 @@ # ***************************************************************************** from .category_types import Category_over_base_ring -from sage.categories.all import Modules +from sage.categories.modules import Modules from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring from sage.categories.tensor import TensorProductsCategory from sage.categories.dual import DualObjectsCategory diff --git a/src/sage/categories/coalgebras_with_basis.py b/src/sage/categories/coalgebras_with_basis.py index b672c37dd27..5518804d649 100644 --- a/src/sage/categories/coalgebras_with_basis.py +++ b/src/sage/categories/coalgebras_with_basis.py @@ -13,7 +13,9 @@ from sage.misc.lazy_attribute import lazy_attribute from sage.misc.lazy_import import LazyImport from sage.categories.category_with_axiom import CategoryWithAxiom_over_base_ring -from sage.categories.all import ModulesWithBasis, tensor, Hom +from sage.categories.modules_with_basis import ModulesWithBasis +from sage.categories.tensor import tensor +from sage.categories.homset import Hom from sage.categories.super_modules import SuperModulesCategory from sage.categories.filtered_modules import FilteredModulesCategory diff --git a/src/sage/categories/examples/algebras_with_basis.py b/src/sage/categories/examples/algebras_with_basis.py index 7ad85cb82ed..f1d05839e2a 100644 --- a/src/sage/categories/examples/algebras_with_basis.py +++ b/src/sage/categories/examples/algebras_with_basis.py @@ -10,7 +10,7 @@ from sage.misc.cachefunc import cached_method from sage.sets.family import Family -from sage.categories.all import AlgebrasWithBasis +from sage.categories.algebras_with_basis import AlgebrasWithBasis from sage.combinat.free_module import CombinatorialFreeModule from sage.combinat.words.words import Words diff --git a/src/sage/categories/examples/commutative_additive_monoids.py b/src/sage/categories/examples/commutative_additive_monoids.py index 945826c22a5..7422604e8e9 100644 --- a/src/sage/categories/examples/commutative_additive_monoids.py +++ b/src/sage/categories/examples/commutative_additive_monoids.py @@ -10,7 +10,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent -from sage.categories.all import CommutativeAdditiveMonoids +from sage.categories.commutative_additive_monoids import CommutativeAdditiveMonoids from .commutative_additive_semigroups import FreeCommutativeAdditiveSemigroup class FreeCommutativeAdditiveMonoid(FreeCommutativeAdditiveSemigroup): diff --git a/src/sage/categories/examples/commutative_additive_semigroups.py b/src/sage/categories/examples/commutative_additive_semigroups.py index ea2fde99bb4..fdda759869a 100644 --- a/src/sage/categories/examples/commutative_additive_semigroups.py +++ b/src/sage/categories/examples/commutative_additive_semigroups.py @@ -12,7 +12,7 @@ from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper from sage.structure.unique_representation import UniqueRepresentation -from sage.categories.all import CommutativeAdditiveSemigroups +from sage.categories.commutative_additive_semigroups import CommutativeAdditiveSemigroups from sage.sets.family import Family class FreeCommutativeAdditiveSemigroup(UniqueRepresentation, Parent): diff --git a/src/sage/categories/examples/finite_coxeter_groups.py b/src/sage/categories/examples/finite_coxeter_groups.py index 71ca54c8a5b..c7937688ef8 100644 --- a/src/sage/categories/examples/finite_coxeter_groups.py +++ b/src/sage/categories/examples/finite_coxeter_groups.py @@ -11,7 +11,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import FiniteCoxeterGroups +from sage.categories.finite_coxeter_groups import FiniteCoxeterGroups from sage.structure.unique_representation import UniqueRepresentation from sage.misc.functional import is_odd, is_even from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix diff --git a/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py b/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py index a3721f106b7..f51b66c49dd 100644 --- a/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py +++ b/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py @@ -9,7 +9,7 @@ #***************************************************************************** from sage.misc.cachefunc import cached_method -from sage.categories.all import FiniteDimensionalAlgebrasWithBasis +from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis from sage.combinat.free_module import CombinatorialFreeModule diff --git a/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py b/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py index 306e0091e12..a975d902e14 100644 --- a/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py +++ b/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py @@ -10,7 +10,7 @@ from sage.misc.cachefunc import cached_method from sage.sets.family import Family -from sage.categories.all import LieAlgebras +from sage.categories.lie_algebras import LieAlgebras from sage.modules.free_module import FreeModule from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation diff --git a/src/sage/categories/examples/finite_monoids.py b/src/sage/categories/examples/finite_monoids.py index f61c28a4032..4d3e8fa7029 100644 --- a/src/sage/categories/examples/finite_monoids.py +++ b/src/sage/categories/examples/finite_monoids.py @@ -13,7 +13,7 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import Monoids +from sage.categories.monoids import Monoids from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ diff --git a/src/sage/categories/examples/finite_weyl_groups.py b/src/sage/categories/examples/finite_weyl_groups.py index a17a48c142e..535d5101101 100644 --- a/src/sage/categories/examples/finite_weyl_groups.py +++ b/src/sage/categories/examples/finite_weyl_groups.py @@ -11,7 +11,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import FiniteWeylGroups +from sage.categories.finite_weyl_groups import FiniteWeylGroups from sage.structure.unique_representation import UniqueRepresentation class SymmetricGroup(UniqueRepresentation, Parent): diff --git a/src/sage/categories/examples/hopf_algebras_with_basis.py b/src/sage/categories/examples/hopf_algebras_with_basis.py index 16bd866c9c6..35b61f3c085 100644 --- a/src/sage/categories/examples/hopf_algebras_with_basis.py +++ b/src/sage/categories/examples/hopf_algebras_with_basis.py @@ -10,9 +10,9 @@ from sage.misc.cachefunc import cached_method from sage.sets.family import Family -from sage.categories.all import HopfAlgebrasWithBasis +from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis from sage.combinat.free_module import CombinatorialFreeModule -from sage.categories.all import tensor +from sage.categories.tensor import tensor class MyGroupAlgebra(CombinatorialFreeModule): r""" diff --git a/src/sage/categories/examples/lie_algebras.py b/src/sage/categories/examples/lie_algebras.py index 3eafe0787f3..135a665cfa3 100644 --- a/src/sage/categories/examples/lie_algebras.py +++ b/src/sage/categories/examples/lie_algebras.py @@ -10,7 +10,7 @@ #from sage.misc.cachefunc import cached_method from sage.sets.family import Family -from sage.categories.all import LieAlgebras +from sage.categories.lie_algebras import LieAlgebras from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper diff --git a/src/sage/categories/examples/magmas.py b/src/sage/categories/examples/magmas.py index 5139041cef0..a4858bc2606 100644 --- a/src/sage/categories/examples/magmas.py +++ b/src/sage/categories/examples/magmas.py @@ -15,7 +15,7 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import Magmas +from sage.categories.magmas import Magmas from sage.sets.family import Family diff --git a/src/sage/categories/examples/monoids.py b/src/sage/categories/examples/monoids.py index c2919a8cc28..7336c680bdf 100644 --- a/src/sage/categories/examples/monoids.py +++ b/src/sage/categories/examples/monoids.py @@ -11,7 +11,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import Monoids +from sage.categories.monoids import Monoids from .semigroups import FreeSemigroup from sage.sets.family import Family diff --git a/src/sage/categories/examples/posets.py b/src/sage/categories/examples/posets.py index 5041df19835..20f461860c9 100644 --- a/src/sage/categories/examples/posets.py +++ b/src/sage/categories/examples/posets.py @@ -10,7 +10,7 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation -from sage.categories.all import Posets +from sage.categories.posets import Posets from sage.structure.element_wrapper import ElementWrapper from sage.sets.set import Set, Set_object_enumerated from sage.sets.positive_integers import PositiveIntegers diff --git a/src/sage/categories/examples/semigroups.py b/src/sage/categories/examples/semigroups.py index 4c4d9a1f4df..5502215ef8a 100644 --- a/src/sage/categories/examples/semigroups.py +++ b/src/sage/categories/examples/semigroups.py @@ -12,7 +12,7 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.element_wrapper import ElementWrapper -from sage.categories.all import Semigroups +from sage.categories.semigroups import Semigroups from sage.sets.family import Family class LeftZeroSemigroup(UniqueRepresentation, Parent): diff --git a/src/sage/categories/examples/semigroups_cython.pyx b/src/sage/categories/examples/semigroups_cython.pyx index ee7a03ddc82..b456c2868f8 100644 --- a/src/sage/categories/examples/semigroups_cython.pyx +++ b/src/sage/categories/examples/semigroups_cython.pyx @@ -4,7 +4,8 @@ Examples of semigroups in cython from sage.structure.parent cimport Parent from sage.structure.element cimport Element -from sage.categories.all import Category, Semigroups +from sage.categories.category import Category +from sage.categories.semigroups import Semigroups from sage.categories.examples.semigroups import LeftZeroSemigroup as LeftZeroSemigroupPython from cpython.object cimport PyObject_RichCompare diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py index 93cc264580d..c4df13b1357 100644 --- a/src/sage/categories/examples/sets_cat.py +++ b/src/sage/categories/examples/sets_cat.py @@ -13,7 +13,7 @@ from sage.categories.sets_cat import Sets from sage.rings.integer import Integer, IntegerWrapper from sage.rings.integer_ring import IntegerRing -from sage.arith.all import is_prime +from sage.arith.misc import is_prime from sage.structure.unique_representation import UniqueRepresentation diff --git a/src/sage/categories/examples/with_realizations.py b/src/sage/categories/examples/with_realizations.py index 06e060f8925..2b75946b1d2 100644 --- a/src/sage/categories/examples/with_realizations.py +++ b/src/sage/categories/examples/with_realizations.py @@ -10,7 +10,9 @@ from sage.misc.cachefunc import cached_method from sage.misc.bindable_class import BindableClass -from sage.categories.all import Rings, Algebras, AlgebrasWithBasis +from sage.categories.rings import Rings +from sage.categories.algebras import Algebras +from sage.categories.algebras_with_basis import AlgebrasWithBasis from sage.categories.realizations import Category_realization_of_parent from sage.structure.unique_representation import UniqueRepresentation from sage.structure.parent import Parent diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py index bb3df827890..e528f758dab 100644 --- a/src/sage/categories/finite_complex_reflection_groups.py +++ b/src/sage/categories/finite_complex_reflection_groups.py @@ -523,7 +523,7 @@ def base_change_matrix(self): [ 1 0] [E(4) 1] """ - from sage.matrix.all import Matrix + from sage.matrix.constructor import Matrix return Matrix(list(self.independent_roots())).inverse() class ElementMethods: @@ -1187,7 +1187,7 @@ def rational_catalan_number(self, p, polynomial=False): sage: W.rational_catalan_number(3, polynomial=True) q^6 + q^4 + q^3 + q^2 + 1 """ - from sage.arith.all import gcd + from sage.arith.misc import GCD as gcd from sage.combinat.q_analogues import q_int h = self.coxeter_number() diff --git a/src/sage/categories/finite_dimensional_bialgebras_with_basis.py b/src/sage/categories/finite_dimensional_bialgebras_with_basis.py index 086892237e6..02f1005e0de 100644 --- a/src/sage/categories/finite_dimensional_bialgebras_with_basis.py +++ b/src/sage/categories/finite_dimensional_bialgebras_with_basis.py @@ -27,5 +27,5 @@ def FiniteDimensionalBialgebrasWithBasis(base_ring): sage: TestSuite(C).run() """ - from sage.categories.all import BialgebrasWithBasis + from sage.categories.bialgebras_with_basis import BialgebrasWithBasis return BialgebrasWithBasis(base_ring).FiniteDimensional() diff --git a/src/sage/categories/finite_dimensional_coalgebras_with_basis.py b/src/sage/categories/finite_dimensional_coalgebras_with_basis.py index 9d1eecf556d..60b135080da 100644 --- a/src/sage/categories/finite_dimensional_coalgebras_with_basis.py +++ b/src/sage/categories/finite_dimensional_coalgebras_with_basis.py @@ -27,5 +27,5 @@ def FiniteDimensionalCoalgebrasWithBasis(base_ring): sage: TestSuite(C).run() """ - from sage.categories.all import CoalgebrasWithBasis + from sage.categories.coalgebras_with_basis import CoalgebrasWithBasis return CoalgebrasWithBasis(base_ring).FiniteDimensional() diff --git a/src/sage/categories/graded_bialgebras.py b/src/sage/categories/graded_bialgebras.py index 6c751db558b..eff325b320e 100644 --- a/src/sage/categories/graded_bialgebras.py +++ b/src/sage/categories/graded_bialgebras.py @@ -26,5 +26,5 @@ def GradedBialgebras(base_ring): sage: TestSuite(C).run() """ - from sage.categories.all import Bialgebras + from sage.categories.bialgebras import Bialgebras return Bialgebras(base_ring).Graded() diff --git a/src/sage/categories/graded_bialgebras_with_basis.py b/src/sage/categories/graded_bialgebras_with_basis.py index 326e32b735d..d1727c0f40c 100644 --- a/src/sage/categories/graded_bialgebras_with_basis.py +++ b/src/sage/categories/graded_bialgebras_with_basis.py @@ -26,5 +26,5 @@ def GradedBialgebrasWithBasis(base_ring): sage: TestSuite(C).run() """ - from sage.categories.all import BialgebrasWithBasis + from sage.categories.bialgebras_with_basis import BialgebrasWithBasis return BialgebrasWithBasis(base_ring).Graded() diff --git a/src/sage/categories/graded_hopf_algebras.py b/src/sage/categories/graded_hopf_algebras.py index ad350212725..c4d5a24e3fe 100644 --- a/src/sage/categories/graded_hopf_algebras.py +++ b/src/sage/categories/graded_hopf_algebras.py @@ -35,5 +35,5 @@ def GradedHopfAlgebras(base_ring): :class:`super Hopf algebras `. """ - from sage.categories.all import HopfAlgebras + from sage.categories.hopf_algebras import HopfAlgebras return HopfAlgebras(base_ring).Graded() diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx index 1bb34eabf3b..e9fb8e45709 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -1330,7 +1330,7 @@ cdef class Section(Map): To: Multivariate Polynomial Ring in x, y over Rational Field """ from sage.categories.homset import Hom - from sage.categories.all import SetsWithPartialMaps + from sage.categories.sets_with_partial_maps import SetsWithPartialMaps Map.__init__(self, Hom(map.codomain(), map.domain(), SetsWithPartialMaps())) self._inverse = map # TODO: Use this attribute somewhere! diff --git a/src/sage/categories/monoid_algebras.py b/src/sage/categories/monoid_algebras.py index f51a8d01ce1..a387d7f74f4 100644 --- a/src/sage/categories/monoid_algebras.py +++ b/src/sage/categories/monoid_algebras.py @@ -33,5 +33,5 @@ def MonoidAlgebras(base_ring): sage: TestSuite(MonoidAlgebras(ZZ)).run() """ - from sage.categories.all import Monoids + from sage.categories.monoids import Monoids return Monoids().Algebras(base_ring) diff --git a/src/sage/categories/schemes.py b/src/sage/categories/schemes.py index df2ec0603cf..aad5a48b7e9 100644 --- a/src/sage/categories/schemes.py +++ b/src/sage/categories/schemes.py @@ -140,7 +140,7 @@ def _call_(self, x): from sage.categories.commutative_rings import CommutativeRings from sage.schemes.generic.spec import Spec from sage.categories.map import Map - from sage.categories.all import Rings + from sage.categories.rings import Rings if x in CommutativeRings(): return Spec(x) elif isinstance(x, Map) and x.category_for().is_subcategory(Rings()): diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 4de83f9c2b1..a94ebc9170b 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -86,7 +86,8 @@ from sage.structure.coerce cimport coercion_model from sage.structure.element import is_Vector from sage.structure.element cimport have_same_parent from sage.misc.verbose import verbose, get_verbose -from sage.categories.all import Fields, IntegralDomains +from sage.categories.fields import Fields +from sage.categories.integral_domains import IntegralDomains from sage.rings.ring import is_Ring from sage.rings.number_field.number_field_base import is_NumberField from sage.rings.integer_ring import ZZ, is_IntegerRing @@ -16821,7 +16822,7 @@ cdef class Matrix(Matrix1): ... ValueError: 'subdivide' keyword must be True or False, not garbage """ - from sage.arith.all import gcd + from sage.arith.misc import GCD as gcd import sage.rings.polynomial.polynomial_ring_constructor from sage.matrix.constructor import (block_diagonal_matrix, companion_matrix) diff --git a/src/sage/matrix/matrix_cdv.pyx b/src/sage/matrix/matrix_cdv.pyx index a964b242c0f..43421c74cb9 100644 --- a/src/sage/matrix/matrix_cdv.pyx +++ b/src/sage/matrix/matrix_cdv.pyx @@ -30,7 +30,7 @@ cpdef hessenbergize_cdvf(Matrix_generic_dense H): a complete discrete valuation field. The pivot on each column is always chosen - with maximal relative precision, which ensures + with maximal relative precision, which ensures the numerical stability of the algorithm. TESTS:: diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx index 2269af40b05..e2ccc0eaa32 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pyx +++ b/src/sage/matrix/matrix_complex_ball_dense.pyx @@ -776,7 +776,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): EXAMPLES:: sage: from sage.matrix.benchmark import hilbert_matrix - sage: mat = hilbert_matrix(3).change_ring(CBF) + sage: mat = hilbert_matrix(3).change_ring(CBF) sage: eigval, eigvec, _ = mat.eigenvectors_right_approx()[0] doctest:...: FutureWarning: This class/method/function is marked as experimental. ... @@ -834,7 +834,7 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): EXAMPLES:: sage: from sage.matrix.benchmark import hilbert_matrix - sage: mat = hilbert_matrix(3).change_ring(CBF) + sage: mat = hilbert_matrix(3).change_ring(CBF) sage: eigval, eigvec, _ = mat.eigenvectors_right()[0] doctest:...: FutureWarning: This class/method/function is marked as experimental. ... diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx index 55e1b7d739e..ddbeb4360b7 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -67,7 +67,8 @@ from .misc import matrix_integer_dense_rational_reconstruction from sage.rings.rational_field import QQ from sage.rings.integer_ring import ZZ -from sage.arith.all import previous_prime, binomial +from sage.arith.misc import previous_prime +from sage.arith.misc import binomial from sage.rings.real_mpfr import create_RealNumber as RealNumber from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index a87ed8d6234..a55a974e0e6 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -78,7 +78,7 @@ from sage.modules.vector_integer_dense cimport Vector_integer_dense from sage.misc.misc import cputime from sage.misc.verbose import verbose, get_verbose -from sage.arith.all import previous_prime +from sage.arith.misc import previous_prime from sage.arith.long cimport integer_check_long_py from sage.arith.power cimport generic_power from sage.structure.element cimport Element diff --git a/src/sage/matrix/matrix_integer_dense_hnf.py b/src/sage/matrix/matrix_integer_dense_hnf.py index acdb0f09cc4..1eacb6e5648 100644 --- a/src/sage/matrix/matrix_integer_dense_hnf.py +++ b/src/sage/matrix/matrix_integer_dense_hnf.py @@ -15,7 +15,8 @@ from sage.rings.integer_ring import ZZ from sage.rings.real_mpfr import RR from sage.rings.integer import Integer -from sage.arith.all import previous_prime, CRT_list +from sage.arith.misc import previous_prime +from sage.arith.misc import CRT_list def max_det_prime(n): diff --git a/src/sage/matrix/matrix_integer_dense_saturation.py b/src/sage/matrix/matrix_integer_dense_saturation.py index a7ce81fc86a..63233d247b5 100644 --- a/src/sage/matrix/matrix_integer_dense_saturation.py +++ b/src/sage/matrix/matrix_integer_dense_saturation.py @@ -4,7 +4,8 @@ from sage.rings.integer_ring import ZZ from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF -from sage.arith.all import binomial, gcd +from sage.arith.misc import binomial +from sage.arith.misc import GCD as gcd from sage.matrix.constructor import identity_matrix, random_matrix from sage.misc.verbose import verbose from sage.misc.randstate import current_randstate diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index b80dcb7da3a..ba2a8af3e8d 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -109,7 +109,7 @@ from libc.stdio cimport snprintf from sage.modules.vector_modn_dense cimport Vector_modn_dense -from sage.arith.all import is_prime +from sage.arith.misc import is_prime from sage.structure.element cimport (Element, Vector, Matrix, ModuleElement, RingElement) from sage.matrix.matrix_dense cimport Matrix_dense diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index 24f2f207f33..f585563886b 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -113,7 +113,7 @@ from sage.misc.verbose import verbose, get_verbose from sage.matrix.matrix2 import Matrix as Matrix2 from .args cimport SparseEntry, MatrixArgs_init -from sage.arith.all import is_prime +from sage.arith.misc import is_prime from sage.structure.element import is_Vector diff --git a/src/sage/matrix/matrix_polynomial_dense.pyx b/src/sage/matrix/matrix_polynomial_dense.pyx index 92502d9632b..cc44242131f 100644 --- a/src/sage/matrix/matrix_polynomial_dense.pyx +++ b/src/sage/matrix/matrix_polynomial_dense.pyx @@ -224,7 +224,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): return self.apply_map(lambda x: x.degree()) from sage.matrix.constructor import matrix zero_degree = min(shifts) - 1 - if row_wise: + if row_wise: return matrix( ZZ, [[ self[i,j].degree() + shifts[j] if self[i,j] != 0 else zero_degree for j in range(self.ncols()) ] for i in range(self.nrows())] ) @@ -1116,7 +1116,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): The row degrees of an empty matrix (`0\times n` or `m\times 0`) is not defined:: - + sage: M = Matrix( pR, 0, 3 ) sage: M.row_degrees() Traceback (most recent call last): @@ -1215,7 +1215,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): n}`. Working row-wise and without shifts, its leading matrix is the matrix in `\Bold{K}^{m \times n}` formed by the leading coefficients of the entries of `M` which reach the degree of the corresponding row. - + More precisely, if working row-wise, let `s_1,\ldots,s_n \in \ZZ` be a shift, and let `(d_1,\ldots,d_m)` denote the shifted row degrees of `M`. Then, the shifted leading matrix of `M` is the matrix in @@ -1239,7 +1239,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): OUTPUT: a matrix over the base field. REFERENCES: - + [Wol1974]_ (Section 2.5, without shifts) and [VBB1992]_ (Section 3). EXAMPLES:: @@ -1335,7 +1335,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): False .. SEEALSO:: - + :meth:`is_popov` . """ if include_zero_vectors: @@ -1385,7 +1385,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): OUTPUT: a boolean value. REFERENCES: - + [Wol1974]_ (Section 2.5, without shifts) and [VBB1992]_ (Section 3). EXAMPLES:: @@ -1441,7 +1441,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): this vector is the index `j` of the rightmost nonzero entry `p_j` such that `\deg(p_j) + s_j` is equal to the shifted row degree of the vector. Then the pivot degree of the vector is the degree `\deg(p_j)`. - + For the zero row, both the leading positions and degree are `-1`. For a `m \times n` polynomial matrix, the leading positions and pivot degrees are the two lists containing the leading positions and the @@ -1465,7 +1465,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): of integers otherwise. REFERENCES: - + [Kai1980]_ (Section 6.7.2, without shifts). EXAMPLES:: @@ -1541,7 +1541,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): self[i,pivot_index[i]].degree()) for i in range(self.nrows()) ] return (pivot_index,pivot_degree) if return_degree else pivot_index - + # now in the column-wise case column_degrees = self.column_degrees(shifts) if shifts is None: @@ -1595,7 +1595,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): OUTPUT: a boolean. REFERENCES: - + [Kai1980]_ (Section 6.7.2, square case without shifts), [MS2003]_ (without shifts), [BLV1999]_ . @@ -1646,7 +1646,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): sage: M = Matrix([ ....: [ 6*x+4, 0, 5*x+1, 0], ....: [ 2, 5*x + 1, 6*x^2+3*x+1, 0], - ....: [2*x^2+5*x+5, 1, 2*x^3+4*x^2+6*x+4, 0] + ....: [2*x^2+5*x+5, 1, 2*x^3+4*x^2+6*x+4, 0] ....: ]) sage: M.is_weak_popov(shifts=[2,1,0], row_wise=False, ordered=True) True @@ -1724,7 +1724,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): OUTPUT: a boolean. REFERENCES: - + For the square case, without shifts: [Pop1972]_ and [Kai1980]_ (Section 6.7.2). For the general case: [BLV2006]_ . @@ -1908,7 +1908,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): False .. SEEALSO:: - + :meth:`hermite_form` . """ # shift for lower echelon @@ -2564,7 +2564,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): - the Hermite normal form `H` of this matrix `A` . - (optional) transformation matrix `U` such that `UA = H` . - + EXAMPLES:: sage: M. = GF(7)[] @@ -2594,7 +2594,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): True .. SEEALSO:: - + :meth:`is_hermite` , :meth:`popov_form` . """ @@ -2923,7 +2923,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): return (self.parent().zero().__copy__(), self) # Step 1: reverse input matrices # Brev = B(1/x) diag(x^(cdeg[i])) - # Arev = A(1/x) diag(x^(d+cdeg[i]-1)) + # Arev = A(1/x) diag(x^(d+cdeg[i]-1)) Brev = B.reverse(degree=cdeg, row_wise=False) Arev = self.reverse(degree=[d+c-1 for c in cdeg], row_wise=False) # Step 2: compute quotient @@ -2953,7 +2953,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): and such a quotient and remainder is returned by the method. Or this matrix equation has no solution and this method fails: this raises ``ValueError``; however this is not a proof that there is no valid - division with remainder (see the last example below). + division with remainder (see the last example below). EXAMPLES:: @@ -3245,12 +3245,12 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): Return ``True`` if and only if this matrix is an approximant basis in ``shifts``-ordered weak Popov form for the polynomial matrix ``pmat`` at order ``order``. - + If ``normal_form`` is ``True``, then the polynomial matrix must furthermore be in ``shifts``-Popov form. An error is raised if the input dimensions are not sound. If a single integer is provided for ``order``, then it is interpreted as a list of repeated integers with - this value. (See :meth:`minimal_approximant_basis` for definitions and + this value. (See :meth:`minimal_approximant_basis` for definitions and more details.) INPUT: @@ -3327,14 +3327,14 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): sage: appbas.is_minimal_approximant_basis(pmat, [8,8], shifts) Traceback (most recent call last): ... - ValueError: order length should be the column dimension + ValueError: order length should be the column dimension of the input matrix sage: appbas.is_minimal_approximant_basis(pmat, \ order, shifts, row_wise=False) Traceback (most recent call last): ... - ValueError: shifts length should be the column dimension + ValueError: shifts length should be the column dimension of the input matrix sage: Matrix(pR, [x^8]).is_minimal_approximant_basis(pmat, 8) @@ -3612,7 +3612,7 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): def _approximant_basis_iterative(self, order, shifts): r""" Return a ``shifts``-ordered weak Popov approximant basis for this - polynomial matrix at order ``order`` + polynomial matrix at order ``order`` (see :meth:`minimal_approximant_basis` for definitions). The output basis is considered row-wise, that is, its rows are diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx index 93efb95781f..10fd2dcabcc 100644 --- a/src/sage/matrix/matrix_rational_dense.pyx +++ b/src/sage/matrix/matrix_rational_dense.pyx @@ -111,7 +111,7 @@ from sage.rings.integer_ring import ZZ, is_IntegerRing from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF import sage.rings.abc from sage.rings.rational_field import QQ -from sage.arith.all import gcd +from sage.arith.misc import GCD as gcd from .matrix2 import decomp_seq from .matrix0 import Matrix as Matrix_base diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index e889cee7905..497f7ad2673 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -679,7 +679,8 @@ def __init__(self, base_ring, nrows, ncols, sparse, implementation): self.__ncols = ncols self.__is_sparse = sparse - from sage.categories.all import Modules, Algebras + from sage.categories.modules import Modules + from sage.categories.algebras import Algebras if nrows == ncols: category = Algebras(base_ring.category()) else: diff --git a/src/sage/matrix/misc.pyx b/src/sage/matrix/misc.pyx index 220f8866b0e..3ac3d26efd2 100644 --- a/src/sage/matrix/misc.pyx +++ b/src/sage/matrix/misc.pyx @@ -38,7 +38,8 @@ from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ from sage.rings.integer cimport Integer -from sage.arith.all import previous_prime, CRT_basis +from sage.arith.misc import previous_prime +from sage.arith.misc import CRT_basis cimport sage.rings.abc from sage.rings.real_mpfr cimport RealNumber diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index e9430f0b086..e4220056f58 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -4047,7 +4047,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): right = py_scalar_to_element(right) if not isinstance(right, Element): right = right.sage() - if not ((right)._parent is self._parent): + from sage.arith.misc import GCD as gcd from sage.arith.all import gcd return coercion_model.bin_op(self, right, gcd) return self._gcd(right) @@ -4081,7 +4081,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): right = py_scalar_to_element(right) if not isinstance(right, Element): right = right.sage() - if not ((right)._parent is self._parent): + from sage.arith.functions import lcm from sage.arith.all import lcm return coercion_model.bin_op(self, right, lcm) return self._lcm(right) diff --git a/src/sage/structure/set_factories_example.py b/src/sage/structure/set_factories_example.py index 44763fda11b..5414edea03d 100644 --- a/src/sage/structure/set_factories_example.py +++ b/src/sage/structure/set_factories_example.py @@ -37,7 +37,7 @@ from sage.structure.element_wrapper import ElementWrapper from sage.structure.set_factories import ( SetFactory, ParentWithSetFactory, TopMostParentPolicy) -from sage.sets.all import DisjointUnionEnumeratedSets +from sage.sets.disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets from sage.sets.family import LazyFamily from sage.categories.enumerated_sets import EnumeratedSets from sage.rings.integer import Integer From 9911481804b7b9fac03695d9d74126a0410c7317 Mon Sep 17 00:00:00 2001 From: Alex Chandler Date: Sun, 29 Jan 2023 11:17:25 -0800 Subject: [PATCH 2/9] src/sage/{categories,matrix,structure}: Manual fixes to imports --- src/sage/categories/category.py | 4 ++-- src/sage/structure/element.pyx | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py index f70455cf1a0..0db7aa21a65 100644 --- a/src/sage/categories/category.py +++ b/src/sage/categories/category.py @@ -153,7 +153,7 @@ class Category(UniqueRepresentation, SageObject): This is achieved as follows:: - sage: from sage.categories.all import Category + sage: from sage.categories.category import Category sage: class EuclideanDomains(Category): ....: # operations on the category itself ....: def super_categories(self): @@ -201,7 +201,7 @@ class inheritance from ``C.parent_class``. :: - sage: from sage.categories.all import Category + sage: from sage.categories.category import Category sage: from sage.misc.lazy_attribute import lazy_attribute sage: class As (Category): ....: def super_categories(self): diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index e4220056f58..92e83bd88ff 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -2226,7 +2226,10 @@ cdef class ElementWithCachedMethod(Element): ....: "cdef class MyParent(Parent):", ....: " Element = MyElement"] sage: cython('\n'.join(cython_code)) # optional - sage.misc.cython - sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category, Objects", + sage: cython_code = ["from sage.misc.cachefunc import cached_method", + ....: "from sage.misc.cachefunc import cached_in_parent_method", + ....: "from sage.categories.category import Category", + ....: "from sage.categories.objects import Objects", ....: "class MyCategory(Category):", ....: " @cached_method", ....: " def super_categories(self):", @@ -2325,7 +2328,10 @@ cdef class ElementWithCachedMethod(Element): ....: from sage.structure.parent cimport Parent ....: cdef class MyParent(Parent): ....: Element = MyElement - ....: from sage.all import cached_method, lazy_attribute, Category, Objects + ....: from sage.misc.cachefunc import cached_method + ....: from sage.misc.cachefunc import cached_in_parent_method + ....: from sage.categories.category import Category + ....: from sage.categories.objects import Objects ....: class MyCategory(Category): ....: @cached_method ....: def super_categories(self): @@ -4048,7 +4054,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): if not isinstance(right, Element): right = right.sage() from sage.arith.misc import GCD as gcd - from sage.arith.all import gcd + from sage.arith.misc import GCD as gcd return coercion_model.bin_op(self, right, gcd) return self._gcd(right) @@ -4082,7 +4088,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): if not isinstance(right, Element): right = right.sage() from sage.arith.functions import lcm - from sage.arith.all import lcm + from sage.arith.functions import lcm return coercion_model.bin_op(self, right, lcm) return self._lcm(right) From 01cded97cb2a4cdbfef84f369a6217d8917edc8f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Jan 2023 16:36:31 -0800 Subject: [PATCH 3/9] src/sage/structure/element.pyx: Fix up --- src/sage/structure/element.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 92e83bd88ff..15d60b32383 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -4053,7 +4053,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): right = py_scalar_to_element(right) if not isinstance(right, Element): right = right.sage() - from sage.arith.misc import GCD as gcd + if not ((right)._parent is self._parent): from sage.arith.misc import GCD as gcd return coercion_model.bin_op(self, right, gcd) return self._gcd(right) @@ -4087,7 +4087,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): right = py_scalar_to_element(right) if not isinstance(right, Element): right = right.sage() - from sage.arith.functions import lcm + if not ((right)._parent is self._parent): from sage.arith.functions import lcm return coercion_model.bin_op(self, right, lcm) return self._lcm(right) From 62032020ad6f73df11cdce1dbeec51aee35ed7cc Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 29 Jan 2023 18:33:04 -0800 Subject: [PATCH 4/9] sage.matrix: Consolidate imports from the same module --- src/sage/matrix/matrix_cyclo_dense.pyx | 3 +- src/sage/matrix/matrix_integer_dense_hnf.py | 9 ++--- .../matrix/matrix_integer_dense_saturation.py | 15 ++++---- src/sage/matrix/misc.pyx | 37 ++++++++----------- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx index ddbeb4360b7..29456daabfe 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -65,10 +65,9 @@ from .matrix_integer_dense cimport _lift_crt from sage.structure.element cimport Matrix as baseMatrix from .misc import matrix_integer_dense_rational_reconstruction +from sage.arith.misc import binomial, previous_prime from sage.rings.rational_field import QQ from sage.rings.integer_ring import ZZ -from sage.arith.misc import previous_prime -from sage.arith.misc import binomial from sage.rings.real_mpfr import create_RealNumber as RealNumber from sage.rings.integer cimport Integer from sage.rings.rational cimport Rational diff --git a/src/sage/matrix/matrix_integer_dense_hnf.py b/src/sage/matrix/matrix_integer_dense_hnf.py index 1eacb6e5648..21415aecad1 100644 --- a/src/sage/matrix/matrix_integer_dense_hnf.py +++ b/src/sage/matrix/matrix_integer_dense_hnf.py @@ -8,15 +8,14 @@ from copy import copy +from sage.arith.misc import CRT_list, previous_prime from sage.misc.misc import cputime from sage.misc.verbose import verbose -from sage.matrix.constructor import (random_matrix, matrix, identity_matrix) - +from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ from sage.rings.real_mpfr import RR -from sage.rings.integer import Integer -from sage.arith.misc import previous_prime -from sage.arith.misc import CRT_list + +from .constructor import identity_matrix, matrix, random_matrix def max_det_prime(n): diff --git a/src/sage/matrix/matrix_integer_dense_saturation.py b/src/sage/matrix/matrix_integer_dense_saturation.py index 63233d247b5..37cf7cf8a69 100644 --- a/src/sage/matrix/matrix_integer_dense_saturation.py +++ b/src/sage/matrix/matrix_integer_dense_saturation.py @@ -2,15 +2,16 @@ Saturation over ZZ """ -from sage.rings.integer_ring import ZZ -from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF -from sage.arith.misc import binomial -from sage.arith.misc import GCD as gcd -from sage.matrix.constructor import identity_matrix, random_matrix -from sage.misc.verbose import verbose +from copy import copy + +from sage.arith.misc import binomial, GCD as gcd from sage.misc.randstate import current_randstate +from sage.misc.verbose import verbose +from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF +from sage.rings.integer_ring import ZZ + from . import matrix_integer_dense_hnf -from copy import copy +from .constructor import identity_matrix, random_matrix def p_saturation(A, p, proof=True): diff --git a/src/sage/matrix/misc.pyx b/src/sage/matrix/misc.pyx index 3ac3d26efd2..25cffdeef0a 100644 --- a/src/sage/matrix/misc.pyx +++ b/src/sage/matrix/misc.pyx @@ -12,21 +12,26 @@ relevant classes and this file deleted. from cysignals.signals cimport sig_check -from sage.ext.mod_int cimport * -from sage.libs.gmp.mpz cimport * -from sage.libs.gmp.mpq cimport * -from sage.libs.mpfr cimport * - -from sage.libs.flint.fmpz cimport fmpz_set_mpz, fmpz_one -from sage.libs.flint.fmpq cimport fmpq_set_mpq, fmpq_canonicalise -from sage.libs.flint.fmpq_mat cimport fmpq_mat_entry_num, fmpq_mat_entry_den, fmpq_mat_entry +cimport sage.rings.abc +from sage.arith.misc import CRT_basis, previous_prime from sage.arith.rational_reconstruction cimport mpq_rational_reconstruction - from sage.data_structures.binary_search cimport * +from sage.ext.mod_int cimport * +from sage.libs.flint.fmpq cimport fmpq_set_mpq, fmpq_canonicalise +from sage.libs.flint.fmpq_mat cimport fmpq_mat_entry_num, fmpq_mat_entry_den, fmpq_mat_entry +from sage.libs.flint.fmpz cimport fmpz_set_mpz, fmpz_one +from sage.libs.gmp.mpq cimport * +from sage.libs.gmp.mpz cimport * +from sage.libs.mpfr cimport * +from sage.misc.verbose import get_verbose, verbose from sage.modules.vector_integer_sparse cimport * -from sage.modules.vector_rational_sparse cimport * from sage.modules.vector_modn_sparse cimport * +from sage.modules.vector_rational_sparse cimport * +from sage.rings.integer cimport Integer +from sage.rings.integer_ring import ZZ +from sage.rings.rational_field import QQ +from sage.rings.real_mpfr cimport RealNumber from .matrix0 cimport Matrix from .matrix_integer_dense cimport Matrix_integer_dense @@ -34,18 +39,6 @@ from .matrix_integer_sparse cimport Matrix_integer_sparse from .matrix_rational_dense cimport Matrix_rational_dense from .matrix_rational_sparse cimport Matrix_rational_sparse -from sage.rings.integer_ring import ZZ -from sage.rings.rational_field import QQ - -from sage.rings.integer cimport Integer -from sage.arith.misc import previous_prime -from sage.arith.misc import CRT_basis - -cimport sage.rings.abc -from sage.rings.real_mpfr cimport RealNumber - - -from sage.misc.verbose import verbose, get_verbose def matrix_integer_dense_rational_reconstruction(Matrix_integer_dense A, Integer N): """ From 6efb63ee2f4d05468f6d836a831e8a971bcd7778 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 7 Feb 2023 18:45:04 -0800 Subject: [PATCH 5/9] src/sage/structure/element.pyx: Fix placement of # optional tag --- src/sage/structure/element.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 15d60b32383..753a7332c4d 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -1137,7 +1137,8 @@ cdef class Element(SageObject): We now create an ``Element`` class where we define ``_richcmp_`` and check that comparison works:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.structure.richcmp cimport rich_to_bool ....: from sage.structure.element cimport Element ....: cdef class FloatCmp(Element): From a6b3c659111a7629d1b33a0be6317fc4600f93f8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 8 Feb 2023 08:59:11 -0800 Subject: [PATCH 6/9] src/sage/structure/element.pyx: Fix placement of remaining # optional tags --- src/sage/structure/element.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 753a7332c4d..582baa47434 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -2317,7 +2317,8 @@ cdef class ElementWithCachedMethod(Element): EXAMPLES:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.structure.element cimport ElementWithCachedMethod ....: cdef class MyElement(ElementWithCachedMethod): ....: cdef public object x @@ -4124,7 +4125,8 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): EXAMPLES:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.structure.element cimport EuclideanDomainElement ....: cdef class MyElt(EuclideanDomainElement): ....: def quo_rem(self, other): @@ -4154,7 +4156,8 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): :: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.structure.element cimport EuclideanDomainElement ....: cdef class MyElt(EuclideanDomainElement): ....: def quo_rem(self, other): From eaffa990ab8103a3fe38f761eeb7e11c7c9fb429 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 8 Feb 2023 09:21:22 -0800 Subject: [PATCH 7/9] Fix placement of remaining '# optional - sage.misc.cython' tags --- src/sage/arith/long.pxd | 7 ++++--- src/sage/cpython/cython_metaclass.pyx | 10 +++++---- src/sage/cpython/string.pyx | 3 ++- src/sage/cpython/wrapperdescr.pxd | 13 ++++++------ src/sage/docs/instancedoc.py | 3 ++- src/sage/env.py | 3 ++- src/sage/ext/memory_allocator.pxd | 21 ++++++++++++------- src/sage/misc/cython.py | 4 ++-- src/sage/misc/sageinspect.py | 7 ++++--- src/sage/misc/superseded.py | 15 ++++++------- src/sage/rings/integer_fake.pxd | 3 ++- .../polynomial/ore_polynomial_element.pyx | 14 +++++++------ src/sage/rings/tate_algebra_ideal.pyx | 3 ++- src/sage/structure/factory.pyx | 4 +++- src/sage/symbolic/pynac.pxi | 3 ++- 15 files changed, 67 insertions(+), 46 deletions(-) diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd index 1c9a53387a0..cd1ed2a6470 100644 --- a/src/sage/arith/long.pxd +++ b/src/sage/arith/long.pxd @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.misc.cython r""" Fast conversion of Python objects to C long """ @@ -113,7 +114,7 @@ cdef inline bint integer_check_long(x, long* value, int* err) except -1: We create a pure Python wrapper of this function:: - sage: cython(''' # optional - sage.misc.cython + sage: cython(''' ....: from sage.arith.long cimport * ....: from sage.rings.integer cimport smallInteger ....: def check_long(x): @@ -246,7 +247,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err): We create a pure Python wrapper of this function:: - sage: cython(''' # optional - sage.misc.cython + sage: cython(''' ....: from sage.arith.long cimport * ....: def check_long_py(x): ....: cdef long value @@ -371,7 +372,7 @@ cdef inline bint is_small_python_int(obj): EXAMPLES:: - sage: cython(''' # optional - sage.misc.cython + sage: cython(''' ....: from sage.arith.long cimport is_small_python_int ....: def is_small_wrapper(x): ....: return is_small_python_int(x) diff --git a/src/sage/cpython/cython_metaclass.pyx b/src/sage/cpython/cython_metaclass.pyx index a846884093e..744d6e54791 100644 --- a/src/sage/cpython/cython_metaclass.pyx +++ b/src/sage/cpython/cython_metaclass.pyx @@ -61,7 +61,8 @@ In Python, this would be ``meta.__init__(cls, name, bases, dict)``. EXAMPLES:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: cimport sage.cpython.cython_metaclass ....: cdef class MyCustomType(): ....: def __getmetaclass__(_): @@ -75,9 +76,9 @@ EXAMPLES:: ....: ''') Calling MyMetaclass.__init__(, None, None, None) Calling MyMetaclass.__init__(, None, None, None) - sage: MyCustomType.__class__ + sage: MyCustomType.__class__ # optional - sage.misc.cython - sage: class MyPythonType(MyDerivedType): + sage: class MyPythonType(MyDerivedType): # optional - sage.misc.cython ....: pass Calling MyMetaclass.__init__(, 'MyPythonType', (,), {...}) @@ -98,7 +99,8 @@ TESTS: Check that a proper exception is raised if ``__getmetaclass__`` returns a non-type:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: cimport sage.cpython.cython_metaclass ....: cdef class MyCustomType(): ....: def __getmetaclass__(_): diff --git a/src/sage/cpython/string.pyx b/src/sage/cpython/string.pyx index 2bd86dbfcf6..bc5fc6f2398 100644 --- a/src/sage/cpython/string.pyx +++ b/src/sage/cpython/string.pyx @@ -6,7 +6,8 @@ TESTS: Check that this can be used outside of Sage (see :trac:`25549`):: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.cpython.string cimport char_to_str ....: print(char_to_str("hello world!")) ....: ''') diff --git a/src/sage/cpython/wrapperdescr.pxd b/src/sage/cpython/wrapperdescr.pxd index fe0a0618a17..d7e67a48ac6 100644 --- a/src/sage/cpython/wrapperdescr.pxd +++ b/src/sage/cpython/wrapperdescr.pxd @@ -39,24 +39,25 @@ cdef inline wrapperbase* get_slotdef(wrapper_descriptor slotwrapper) except NULL TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.cpython.wrapperdescr cimport get_slotdef ....: from cpython.long cimport PyLong_FromVoidPtr ....: def py_get_slotdef(slotwrapper): ....: return PyLong_FromVoidPtr(get_slotdef(slotwrapper)) ....: ''') - sage: py_get_slotdef(object.__init__) # random + sage: py_get_slotdef(object.__init__) # random # optional - sage.misc.cython 140016903442416 - sage: py_get_slotdef(bytes.__lt__) # random + sage: py_get_slotdef(bytes.__lt__) # random # optional - sage.misc.cython 140016903441800 - sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(Integer.__lt__) + sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(Integer.__lt__) # optional - sage.misc.cython True - sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(bytes.__gt__) + sage: py_get_slotdef(bytes.__lt__) == py_get_slotdef(bytes.__gt__) # optional - sage.misc.cython False sage: class X(): ....: def __eq__(self, other): ....: return False - sage: py_get_slotdef(X.__eq__) + sage: py_get_slotdef(X.__eq__) # optional - sage.misc.cython Traceback (most recent call last): ... TypeError: Cannot convert ... to wrapper_descriptor diff --git a/src/sage/docs/instancedoc.py b/src/sage/docs/instancedoc.py index e24368e4943..5b03886ef02 100644 --- a/src/sage/docs/instancedoc.py +++ b/src/sage/docs/instancedoc.py @@ -36,7 +36,8 @@ For a Cython ``cdef class``, a decorator cannot be used. Instead, call :func:`instancedoc` as a function after defining the class:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.misc.instancedoc import instancedoc ....: cdef class Y: ....: "Class docstring" diff --git a/src/sage/env.py b/src/sage/env.py index 911f34b1bc6..63038a399dc 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -448,7 +448,8 @@ def cython_aliases(required_modules=None, We can use ``cython.parallel`` regardless of whether OpenMP is supported. This will run in parallel, if OpenMP is supported:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: #distutils: extra_compile_args = OPENMP_CFLAGS ....: #distutils: extra_link_args = OPENMP_CFLAGS ....: from cython.parallel import prange diff --git a/src/sage/ext/memory_allocator.pxd b/src/sage/ext/memory_allocator.pxd index b612df2110c..4e9f9e1c7ae 100644 --- a/src/sage/ext/memory_allocator.pxd +++ b/src/sage/ext/memory_allocator.pxd @@ -56,7 +56,8 @@ cdef class MemoryAllocator: TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef void* ptr @@ -64,7 +65,8 @@ cdef class MemoryAllocator: ....: ptr = mem.aligned_malloc(2**i, 4048) ....: assert ptr == ( ptr) & ~(2**i-1) ....: ''') - doctest:...: DeprecationWarning: this class is deprecated; use the class from the python package `memory_allocator` + doctest:...: DeprecationWarning: this class is deprecated; + use the class from the python package `memory_allocator` See https://trac.sagemath.org/31591 for details. """ cdef size_t extra = alignment - 1 @@ -85,7 +87,8 @@ cdef class MemoryAllocator: TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: def foo(): ....: cdef MemoryAllocator mem = MemoryAllocator() @@ -94,8 +97,9 @@ cdef class MemoryAllocator: ....: ptr = mem.aligned_calloc(2**i, i, 2**i) ....: assert ptr == ( ptr) & ~(2**i-1) ....: ''') - sage: foo() - doctest:...: DeprecationWarning: this class is deprecated; use the class from the python package `memory_allocator` + sage: foo() # optional - sage.misc.cython + doctest:...: DeprecationWarning: this class is deprecated; + use the class from the python package `memory_allocator` See https://trac.sagemath.org/31591 for details. """ # Find extra such that (nmemb + extra) * size >= nmemb * size + alignment - 1 @@ -120,7 +124,8 @@ cdef class MemoryAllocator: TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: def foo(): ....: cdef MemoryAllocator mem = MemoryAllocator() @@ -129,8 +134,8 @@ cdef class MemoryAllocator: ....: ptr = mem.aligned_allocarray(2**i, i, 2**i) ....: assert ptr == ( ptr) & ~(2**i-1) ....: ''') - sage: foo() # random # might raise deprecation warning - sage: foo() + sage: foo() # random # might raise deprecation warning # optional - sage.misc.cython + sage: foo() # optional - sage.misc.cython """ # Find extra such that (nmemb + extra) * size >= nmemb * size + alignment - 1 # ⇔ extra * size >= alignment - 1 diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 9df8e3fa376..5da117f9578 100644 --- a/src/sage/misc/cython.py +++ b/src/sage/misc/cython.py @@ -171,7 +171,7 @@ def cython(filename, verbose=0, compile_message=False, sage: os.chdir(d) sage: with open("helper.pxd", 'w') as f: ....: _ = f.write("cdef inline int the_answer(): return 42") - sage: cython(''' # optional - sage.misc.cython + sage: cython(''' ....: from helper cimport the_answer ....: print(the_answer()) ....: ''') @@ -208,7 +208,7 @@ def cython(filename, verbose=0, compile_message=False, As of :trac:`29139` the default is ``cdivision=True``:: - sage: cython(''' # optional - sage.misc.cython + sage: cython(''' ....: cdef size_t foo = 3/2 ....: ''') """ diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 2c172acdfcf..73cedde0847 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1372,13 +1372,14 @@ def sage_getfile(obj): A problem fixed in :trac:`16309`:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: class Bar: pass ....: cdef class Foo: pass ....: ''') - sage: sage_getfile(Bar) + sage: sage_getfile(Bar) # optional - sage.misc.cython '...pyx' - sage: sage_getfile(Foo) + sage: sage_getfile(Foo) # optional - sage.misc.cython '...pyx' By :trac:`18249`, we return an empty string for Python builtins. In that diff --git a/src/sage/misc/superseded.py b/src/sage/misc/superseded.py index 2bc69b0ffb8..124ce4427f2 100644 --- a/src/sage/misc/superseded.py +++ b/src/sage/misc/superseded.py @@ -108,16 +108,17 @@ def deprecation_cython(trac_number, message, stacklevel=3): with the same callsite reference as `deprecation` in a python function, whereas `deprecation` in a cython function does not:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.misc.superseded import deprecation_cython, deprecation ....: def foo1(): - ....: deprecation_cython(100,"boo") + ....: deprecation_cython(100, "boo") ....: def foo2(): - ....: deprecation(100,"boo") + ....: deprecation(100, "boo") ....: ''') sage: def foo3(): - ....: deprecation(100,"boo") - sage: if True: # Execute the three "with" blocks as one doctest + ....: deprecation(100, "boo") + sage: if True: # Execute the three "with" blocks as one doctest # optional - sage.misc.cython ....: with warnings.catch_warnings(record=True) as w1: ....: warnings.simplefilter("always") ....: foo1() @@ -127,9 +128,9 @@ def deprecation_cython(trac_number, message, stacklevel=3): ....: with warnings.catch_warnings(record=True) as w3: ....: warnings.simplefilter("always") ....: foo3() - sage: w1[0].filename == w3[0].filename + sage: w1[0].filename == w3[0].filename # optional - sage.misc.cython True - sage: w2[0].filename == w3[0].filename + sage: w2[0].filename == w3[0].filename # optional - sage.misc.cython False """ warning(trac_number, message, DeprecationWarning, stacklevel) diff --git a/src/sage/rings/integer_fake.pxd b/src/sage/rings/integer_fake.pxd index de7672fa22e..d900190f74d 100644 --- a/src/sage/rings/integer_fake.pxd +++ b/src/sage/rings/integer_fake.pxd @@ -17,7 +17,8 @@ This provides two functions: TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.rings.integer_fake cimport Integer_AS_MPZ, is_Integer ....: from sage.rings.integer cimport Integer ....: cdef Integer x = Integer(123456789) diff --git a/src/sage/rings/polynomial/ore_polynomial_element.pyx b/src/sage/rings/polynomial/ore_polynomial_element.pyx index b9fa812bd7a..4bd06bd0ce4 100644 --- a/src/sage/rings/polynomial/ore_polynomial_element.pyx +++ b/src/sage/rings/polynomial/ore_polynomial_element.pyx @@ -1301,7 +1301,8 @@ cdef class OrePolynomial(AlgebraElement): TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.rings.polynomial.ore_polynomial_element cimport OrePolynomial ....: def left_lcm_cofactor(OrePolynomial P, OrePolynomial Q): ....: return P._left_lcm_cofactor(Q) @@ -1315,8 +1316,8 @@ cdef class OrePolynomial(AlgebraElement): sage: P = S.random_element(degree=2) * D sage: Q = S.random_element(degree=2) * D sage: L = P.left_lcm(Q) - sage: U = left_lcm_cofactor(P, Q) - sage: (U*P).right_monic() == L + sage: U = left_lcm_cofactor(P, Q) # optional - sage.misc.cython + sage: (U*P).right_monic() == L # optional - sage.misc.cython True """ cdef OrePolynomial Q, R, T @@ -1378,7 +1379,8 @@ cdef class OrePolynomial(AlgebraElement): TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.rings.polynomial.ore_polynomial_element cimport OrePolynomial ....: def right_lcm_cofactor(OrePolynomial P, OrePolynomial Q): ....: return P._right_lcm_cofactor(Q) @@ -1392,8 +1394,8 @@ cdef class OrePolynomial(AlgebraElement): sage: P = D * S.random_element(degree=2) sage: Q = D * S.random_element(degree=2) sage: L = P.right_lcm(Q) - sage: U = right_lcm_cofactor(P, Q) - sage: (P*U).left_monic() == L + sage: U = right_lcm_cofactor(P, Q) # optional - sage.misc.cython + sage: (P*U).left_monic() == L # optional - sage.misc.cython True """ cdef OrePolynomial Q, R, T diff --git a/src/sage/rings/tate_algebra_ideal.pyx b/src/sage/rings/tate_algebra_ideal.pyx index 58025c6069d..9feac33ea91 100644 --- a/src/sage/rings/tate_algebra_ideal.pyx +++ b/src/sage/rings/tate_algebra_ideal.pyx @@ -625,7 +625,8 @@ cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElemen TESTS:: - sage: cython(''' # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' ....: from sage.rings.tate_algebra_ideal cimport regular_reduce ....: def python_regular_reduce(gb, s, v, stopval): ....: return regular_reduce(gb, s, v, stopval) diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx index a4a13186973..a1a28a0da7a 100644 --- a/src/sage/structure/factory.pyx +++ b/src/sage/structure/factory.pyx @@ -222,7 +222,9 @@ cdef class UniqueFactory(SageObject): Let us try again, with a Cython class that does allow weak references. Now, creation of an instance using the factory works:: - sage: cython('''cdef class C: # optional - sage.misc.cython + sage: cython( # optional - sage.misc.cython + ....: ''' + ....: cdef class C: ....: cdef __weakref__ ....: ''') ....: diff --git a/src/sage/symbolic/pynac.pxi b/src/sage/symbolic/pynac.pxi index e6ab54f4e0b..4015657b951 100644 --- a/src/sage/symbolic/pynac.pxi +++ b/src/sage/symbolic/pynac.pxi @@ -3,7 +3,8 @@ Declarations for pynac, a Python frontend for ginac Check that we can externally cimport this (:trac:`18825`):: - sage: cython(''' # long time; random compiler warnings # optional - sage.misc.cython + sage: cython( # long time; random compiler warnings # optional - sage.misc.cython + ....: ''' ....: from sage.symbolic cimport expression ....: ''') """ From e02e213a814fe99fb1b80a0dce6abb300b5a3e4c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 8 Feb 2023 12:48:41 -0800 Subject: [PATCH 8/9] src/sage/structure/element.pyx: Restore import of lazy_attribute in cython example --- src/sage/structure/element.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 582baa47434..71dc96633b1 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -2331,7 +2331,7 @@ cdef class ElementWithCachedMethod(Element): ....: cdef class MyParent(Parent): ....: Element = MyElement ....: from sage.misc.cachefunc import cached_method - ....: from sage.misc.cachefunc import cached_in_parent_method + ....: from sage.misc.lazy_attribute import lazy_attribute ....: from sage.categories.category import Category ....: from sage.categories.objects import Objects ....: class MyCategory(Category): From 25783a4d42d6a6b6670e45e46f4be2b612b52dfd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 16 Feb 2023 14:45:21 -0800 Subject: [PATCH 9/9] Replace relative imports by absolute imports because pytest --- src/sage/matrix/matrix_integer_dense_hnf.py | 3 +-- src/sage/matrix/matrix_integer_dense_saturation.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sage/matrix/matrix_integer_dense_hnf.py b/src/sage/matrix/matrix_integer_dense_hnf.py index 21415aecad1..41fd6ca8dde 100644 --- a/src/sage/matrix/matrix_integer_dense_hnf.py +++ b/src/sage/matrix/matrix_integer_dense_hnf.py @@ -9,14 +9,13 @@ from copy import copy from sage.arith.misc import CRT_list, previous_prime +from sage.matrix.constructor import identity_matrix, matrix, random_matrix from sage.misc.misc import cputime from sage.misc.verbose import verbose from sage.rings.integer import Integer from sage.rings.integer_ring import ZZ from sage.rings.real_mpfr import RR -from .constructor import identity_matrix, matrix, random_matrix - def max_det_prime(n): """ diff --git a/src/sage/matrix/matrix_integer_dense_saturation.py b/src/sage/matrix/matrix_integer_dense_saturation.py index 37cf7cf8a69..365c8d830bf 100644 --- a/src/sage/matrix/matrix_integer_dense_saturation.py +++ b/src/sage/matrix/matrix_integer_dense_saturation.py @@ -5,14 +5,13 @@ from copy import copy from sage.arith.misc import binomial, GCD as gcd +from sage.matrix import matrix_integer_dense_hnf +from sage.matrix.constructor import identity_matrix, random_matrix from sage.misc.randstate import current_randstate from sage.misc.verbose import verbose from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.rings.integer_ring import ZZ -from . import matrix_integer_dense_hnf -from .constructor import identity_matrix, random_matrix - def p_saturation(A, p, proof=True): """