Skip to content

Commit 9cf6aa1

Browse files
author
Release Manager
committed
Trac #34956: sage.{misc,monoids,sets}: Replace imports from sage.*.all for namespace packages
Using `./sage -fiximports` from #34945. Also remove trailing whitespace in the affected files. Part of Meta-ticket #32414 URL: https://trac.sagemath.org/34956 Reported by: mkoeppe Ticket author(s): Alex Chandler, Matthias Koeppe Reviewer(s): Travis Scrimshaw
2 parents 3095f51 + a8a3d6e commit 9cf6aa1

14 files changed

+153
-121
lines changed

src/sage/env.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
1212
sage: env = {k:v for (k,v) in os.environ.items() if not k.startswith("SAGE_")}
1313
sage: from subprocess import check_output
14-
sage: cmd = "from sage.all import SAGE_ROOT, SAGE_LOCAL; print((SAGE_ROOT, SAGE_LOCAL))"
14+
sage: environment = "sage.all"
15+
sage: cmd = f"from {environment} import SAGE_ROOT, SAGE_LOCAL; print((SAGE_ROOT, SAGE_LOCAL))"
1516
sage: out = check_output([sys.executable, "-c", cmd], env=env).decode().strip() # long time
1617
sage: out == repr((SAGE_ROOT, SAGE_LOCAL)) # long time
1718
True

src/sage/misc/cachefunc.pyx

+5-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ approach is still needed for cpdef methods::
6969
sage: cython_code = ['cpdef test_meth(self,x):',
7070
....: ' "some doc for a wrapped cython method"',
7171
....: ' return -x',
72-
....: 'from sage.all import cached_method',
72+
....: 'from sage.misc.cachefunc import cached_method',
7373
....: 'from sage.structure.parent cimport Parent',
7474
....: 'cdef class MyClass(Parent):',
7575
....: ' @cached_method',
@@ -107,7 +107,10 @@ By :trac:`11115`, even if a parent does not allow attribute
107107
assignment, it can inherit a cached method from the parent class of a
108108
category (previously, the cache would have been broken)::
109109
110-
sage: cython_code = ["from sage.all import cached_method, cached_in_parent_method, Category, Objects",
110+
sage: cython_code = ["from sage.misc.cachefunc import cached_method",
111+
....: "from sage.misc.cachefunc import cached_in_parent_method",
112+
....: "from sage.categories.category import Category",
113+
....: "from sage.categories.objects import Objects",
111114
....: "class MyCategory(Category):",
112115
....: " @cached_method",
113116
....: " def super_categories(self):",

src/sage/misc/fast_methods.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class Singleton(WithEqualityById, metaclass=ClasscallMetaclass):
311311
EXAMPLES::
312312
313313
sage: from sage.misc.fast_methods import Singleton
314-
sage: class C(Singleton, Parent):
314+
sage: class C(Singleton, Parent):
315315
....: def __init__(self):
316316
....: print("creating singleton")
317317
....: Parent.__init__(self, base=ZZ, category=Rings())
@@ -321,7 +321,7 @@ class Singleton(WithEqualityById, metaclass=ClasscallMetaclass):
321321
sage: __main__.C = C # ... in doctests
322322
sage: loads(dumps(c)) is copy(c) is C() # indirect doctest
323323
True
324-
"""
324+
"""
325325
return self
326326

327327
def __reduce__(self):
@@ -332,7 +332,7 @@ class Singleton(WithEqualityById, metaclass=ClasscallMetaclass):
332332
EXAMPLES::
333333
334334
sage: from sage.misc.fast_methods import Singleton
335-
sage: class C(Singleton, Parent):
335+
sage: class C(Singleton, Parent):
336336
....: def __init__(self):
337337
....: print("creating singleton")
338338
....: Parent.__init__(self, base=ZZ, category=Rings())
@@ -349,5 +349,5 @@ class Singleton(WithEqualityById, metaclass=ClasscallMetaclass):
349349
instance.If the class is replaced by a sub-sub-class after creation
350350
of the instance, pickling fails. See the doctest
351351
in :class:`Singleton`.
352-
"""
352+
"""
353353
return self.__class__, ()

src/sage/misc/functional.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ def squarefree_part(x):
18221822
return x.squarefree_part()
18231823
except AttributeError:
18241824
pass
1825-
from sage.arith.all import factor
1825+
from sage.arith.misc import factor
18261826
from sage.structure.all import parent
18271827
F = factor(x)
18281828
n = parent(x)(1)

src/sage/misc/latex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def float_function(x):
409409
sage: latex(float(2e-13))
410410
2 \times 10^{-13}
411411
"""
412-
from sage.all import RDF
412+
from sage.rings.real_double import RDF
413413
return latex(RDF(x))
414414

415415

0 commit comments

Comments
 (0)