diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd index 4addc8cfc89..b5ab13aba5a 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/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/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/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 9c91c2af549..f1897267140 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 a569cc83849..5b3a00a2328 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -1331,7 +1331,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/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 ac279ed5da3..d1a87df74ce 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -449,7 +449,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 5ada54f9535..c4f2028f4e4 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://github.com/sagemath/sage/issues/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://github.com/sagemath/sage/issues/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/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index ab96459e66e..7fd2108e4d2 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 @@ -16878,7 +16879,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 2a9f00d19ad..8ba87305636 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..29456daabfe 100644 --- a/src/sage/matrix/matrix_cyclo_dense.pyx +++ b/src/sage/matrix/matrix_cyclo_dense.pyx @@ -65,9 +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.all import previous_prime, 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 b9f9d5791b4..9b5a5676764 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..41fd6ca8dde 100644 --- a/src/sage/matrix/matrix_integer_dense_hnf.py +++ b/src/sage/matrix/matrix_integer_dense_hnf.py @@ -8,14 +8,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.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.all import previous_prime, 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..365c8d830bf 100644 --- a/src/sage/matrix/matrix_integer_dense_saturation.py +++ b/src/sage/matrix/matrix_integer_dense_saturation.py @@ -2,14 +2,15 @@ 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.all import binomial, gcd +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.verbose import verbose from sage.misc.randstate import current_randstate -from . import matrix_integer_dense_hnf -from copy import copy +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 def p_saturation(A, p, proof=True): diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 2f2acfd562a..abf29badce6 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 1bf2255b8f3..8e7e49cd90c 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 73c5b445de7..afd06c9db20 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..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,17 +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.all import previous_prime, 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): """ diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 3f02e9e3a70..109e555abe4 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 83ad5d8d4c0..5099351a9c2 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 017b2ec2883..c158317ca5a 100644 --- a/src/sage/misc/superseded.py +++ b/src/sage/misc/superseded.py @@ -107,16 +107,17 @@ def deprecation_cython(issue_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() @@ -126,9 +127,9 @@ def deprecation_cython(issue_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(issue_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 820c758496c..4db1a1652ff 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 17031adcec2..84d1b05b3db 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/element.pyx b/src/sage/structure/element.pyx index 6ad3075c5f4..144b6508769 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): @@ -2226,7 +2227,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):", @@ -2313,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 @@ -2325,7 +2330,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.lazy_attribute import lazy_attribute + ....: from sage.categories.category import Category + ....: from sage.categories.objects import Objects ....: class MyCategory(Category): ....: @cached_method ....: def super_categories(self): @@ -4048,7 +4056,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): if not isinstance(right, Element): right = right.sage() if not ((right)._parent is self._parent): - 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 +4090,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): if not isinstance(right, Element): right = right.sage() if not ((right)._parent is self._parent): - from sage.arith.all import lcm + from sage.arith.functions import lcm return coercion_model.bin_op(self, right, lcm) return self._lcm(right) @@ -4117,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): @@ -4147,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): 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/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 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 ....: ''') """