Skip to content

Commit 64b28d8

Browse files
author
Matthias Koeppe
committed
sage.structure: Update # needs
1 parent ccecd75 commit 64b28d8

File tree

10 files changed

+96
-75
lines changed

10 files changed

+96
-75
lines changed

src/sage/structure/category_object.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ cdef class CategoryObject(SageObject):
565565
566566
EXAMPLES::
567567
568-
sage: from sage.modules.module import Module # needs sage.modules
569-
sage: Module(ZZ).base_ring() # needs sage.modules
568+
sage: from sage.modules.module import Module
569+
sage: Module(ZZ).base_ring()
570570
Integer Ring
571571
572572
sage: F = FreeModule(ZZ, 3) # needs sage.modules

src/sage/structure/coerce.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def parent_is_numerical(P):
372372
False
373373
sage: [parent_is_numerical(R) for R in [QQ['x'], QQ[['x']], str]]
374374
[False, False, False]
375-
sage: [parent_is_numerical(R) for R in [RIF, RBF, CIF, CBF]]
375+
sage: [parent_is_numerical(R) for R in [RIF, RBF, CIF, CBF]] # needs sage.libs.flint
376376
[False, False, False, False]
377377
"""
378378
if not isinstance(P, Parent):
@@ -405,7 +405,7 @@ def parent_is_real_numerical(P):
405405
[False, False, False]
406406
sage: parent_is_real_numerical(SR) # needs sage.symbolic
407407
False
408-
sage: [parent_is_real_numerical(R) for R in [RIF, RBF, CIF, CBF]]
408+
sage: [parent_is_real_numerical(R) for R in [RIF, RBF, CIF, CBF]] # needs sage.libs.flint
409409
[False, False, False, False]
410410
"""
411411
if not isinstance(P, Parent):
@@ -1870,6 +1870,7 @@ cdef class CoercionModel:
18701870
18711871
Check that :trac:`18221` is fixed::
18721872
1873+
sage: # needs sage.combinat sage.modules
18731874
sage: F.<x> = FreeAlgebra(QQ) # needs sage.combinat sage.modules
18741875
sage: x / 2 # needs sage.combinat sage.modules
18751876
1/2*x

src/sage/structure/coerce_actions.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,23 +775,23 @@ cdef class IntegerMulAction(IntegerAction):
775775
776776
This used to hang before :trac:`17844`::
777777
778-
sage: E = EllipticCurve(GF(5), [4,0]) # needs sage.rings.finite_rings
779-
sage: P = E.random_element() # needs sage.rings.finite_rings
780-
sage: (-2^63)*P # needs sage.rings.finite_rings
778+
sage: E = EllipticCurve(GF(5), [4,0]) # needs sage.schemes
779+
sage: P = E.random_element() # needs sage.schemes
780+
sage: (-2^63)*P # needs sage.schemes
781781
(0 : 1 : 0)
782782
783783
Check that large multiplications can be interrupted::
784784
785-
sage: alarm(0.001); 2^(10^7) * P # needs sage.rings.finite_rings
785+
sage: alarm(0.001); 2^(10^7) * P # needs sage.schemes
786786
Traceback (most recent call last):
787787
...
788788
AlarmInterrupt
789789
790790
Verify that cysignals correctly detects that the above
791791
exception has been handled::
792792
793-
sage: from cysignals.tests import print_sig_occurred # needs sage.rings.finite_rings
794-
sage: print_sig_occurred() # needs sage.rings.finite_rings
793+
sage: from cysignals.tests import print_sig_occurred
794+
sage: print_sig_occurred() # needs sage.schemes
795795
No current exception
796796
"""
797797
cdef int err = 0

src/sage/structure/element.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cpdef inline parent(x):
3333
sage: b = 42/1
3434
sage: parent(b)
3535
Rational Field
36-
sage: c = 42.0 # needs sage.rings.real_mpfr
36+
sage: c = 42.0
3737
sage: parent(c) # needs sage.rings.real_mpfr
3838
Real Field with 53 bits of precision
3939
@@ -132,12 +132,12 @@ cpdef inline bint have_same_parent(left, right):
132132
These have different types but the same parent::
133133
134134
sage: a = RLF(2)
135-
sage: b = exp(a) # needs sage.symbolic
136-
sage: type(a) # needs sage.symbolic
135+
sage: b = exp(a)
136+
sage: type(a)
137137
<... 'sage.rings.real_lazy.LazyWrapper'>
138-
sage: type(b) # needs sage.symbolic
138+
sage: type(b)
139139
<... 'sage.rings.real_lazy.LazyNamedUnop'>
140-
sage: have_same_parent(a, b) # needs sage.symbolic
140+
sage: have_same_parent(a, b)
141141
True
142142
"""
143143
return HAVE_SAME_PARENT(classify_elements(left, right))

src/sage/structure/element.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,13 +4328,14 @@ cdef class FieldElement(CommutativeRingElement):
43284328
43294329
EXAMPLES::
43304330
4331+
sage: # needs sage.rings.number_field
43314332
sage: x = polygen(ZZ, 'x')
4332-
sage: K.<b> = NumberField(x^4 + x^2 + 2/3) # needs sage.rings.number_field
4333-
sage: c = (1+b) // (1-b); c # needs sage.rings.number_field
4333+
sage: K.<b> = NumberField(x^4 + x^2 + 2/3)
4334+
sage: c = (1+b) // (1-b); c
43344335
3/4*b^3 + 3/4*b^2 + 3/2*b + 1/2
4335-
sage: (1+b) / (1-b) == c # needs sage.rings.number_field
4336+
sage: (1+b) / (1-b) == c
43364337
True
4337-
sage: c * (1-b) # needs sage.rings.number_field
4338+
sage: c * (1-b)
43384339
b + 1
43394340
"""
43404341
return self._div_(right)

src/sage/structure/factorization.py

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,57 +66,61 @@
6666
This more complicated example involving polynomials also illustrates
6767
that the unit part is not discarded from factorizations::
6868
69+
sage: # needs sage.libs.pari
6970
sage: x = QQ['x'].0
7071
sage: f = -5*(x-2)*(x-3)
7172
sage: f
7273
-5*x^2 + 25*x - 30
73-
sage: F = f.factor(); F # optional - sage.libs.pari
74+
sage: F = f.factor(); F
7475
(-5) * (x - 3) * (x - 2)
75-
sage: F.unit() # optional - sage.libs.pari
76+
sage: F.unit()
7677
-5
77-
sage: F.value() # optional - sage.libs.pari
78+
sage: F.value()
7879
-5*x^2 + 25*x - 30
7980
8081
The underlying list is the list of pairs `(p_i, e_i)`, where each
8182
`p_i` is a 'prime' and each `e_i` is an integer. The unit part
8283
is discarded by the list::
8384
84-
sage: list(F) # optional - sage.libs.pari
85+
sage: # needs sage.libs.pari
86+
sage: list(F)
8587
[(x - 3, 1), (x - 2, 1)]
86-
sage: len(F) # optional - sage.libs.pari
88+
sage: len(F)
8789
2
88-
sage: F[1] # optional - sage.libs.pari
90+
sage: F[1]
8991
(x - 2, 1)
9092
9193
In the ring `\ZZ[x]`, the integer `-5` is not a unit, so the
9294
factorization has three factors::
9395
96+
sage: # needs sage.libs.pari
9497
sage: x = ZZ['x'].0
9598
sage: f = -5*(x-2)*(x-3)
9699
sage: f
97100
-5*x^2 + 25*x - 30
98-
sage: F = f.factor(); F # optional - sage.libs.pari
101+
sage: F = f.factor(); F
99102
(-1) * 5 * (x - 3) * (x - 2)
100-
sage: F.universe() # optional - sage.libs.pari
103+
sage: F.universe()
101104
Univariate Polynomial Ring in x over Integer Ring
102-
sage: F.unit() # optional - sage.libs.pari
105+
sage: F.unit()
103106
-1
104-
sage: list(F) # optional - sage.libs.pari
107+
sage: list(F)
105108
[(5, 1), (x - 3, 1), (x - 2, 1)]
106-
sage: F.value() # optional - sage.libs.pari
109+
sage: F.value()
107110
-5*x^2 + 25*x - 30
108-
sage: len(F) # optional - sage.libs.pari
111+
sage: len(F)
109112
3
110113
111114
On the other hand, -1 is a unit in `\ZZ`, so it is included in the unit::
112115
116+
sage: # needs sage.libs.pari
113117
sage: x = ZZ['x'].0
114-
sage: f = -1*(x-2)*(x-3) # optional - sage.libs.pari
115-
sage: F = f.factor(); F # optional - sage.libs.pari
118+
sage: f = -1 * (x-2) * (x-3)
119+
sage: F = f.factor(); F
116120
(-1) * (x - 3) * (x - 2)
117-
sage: F.unit() # optional - sage.libs.pari
121+
sage: F.unit()
118122
-1
119-
sage: list(F) # optional - sage.libs.pari
123+
sage: list(F)
120124
[(x - 3, 1), (x - 2, 1)]
121125
122126
Factorizations can involve fairly abstract mathematical objects::
@@ -133,6 +137,7 @@
133137
134138
135139
sage: # needs sage.rings.number_field
140+
sage: x = ZZ['x'].0
136141
sage: K.<a> = NumberField(x^2 + 3); K
137142
Number Field in a with defining polynomial x^2 + 3
138143
sage: f = K.factor(15); f
@@ -580,15 +585,19 @@ def is_commutative(self) -> bool:
580585
sage: F = factor(2006)
581586
sage: F.is_commutative()
582587
True
583-
sage: K = QuadraticField(23, 'a') # optional - sage.rings.number_field
584-
sage: F = K.factor(13) # optional - sage.rings.number_field
585-
sage: F.is_commutative() # optional - sage.rings.number_field
588+
589+
sage: # needs sage.rings.number_field
590+
sage: K = QuadraticField(23, 'a')
591+
sage: F = K.factor(13)
592+
sage: F.is_commutative()
586593
True
587-
sage: R.<x,y,z> = FreeAlgebra(QQ, 3) # optional - sage.combinat sage.modules
588-
sage: F = Factorization([(z, 2)], 3) # optional - sage.combinat sage.modules
589-
sage: F.is_commutative() # optional - sage.combinat sage.modules
594+
595+
sage: # needs sage.combinat sage.modules
596+
sage: R.<x,y,z> = FreeAlgebra(QQ, 3)
597+
sage: F = Factorization([(z, 2)], 3)
598+
sage: F.is_commutative()
590599
False
591-
sage: (F*F^-1).is_commutative() # optional - sage.combinat sage.modules
600+
sage: (F*F^-1).is_commutative()
592601
False
593602
"""
594603
try:

src/sage/structure/formal_sum.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ def __init__(self, x, parent=None, check=True, reduce=True):
104104
sage: a.reduce()
105105
sage: a
106106
4*2/3 - 5*7
107-
sage: FormalSum([(1, 2/3), (3, 2/3), (-5, 7)], parent=FormalSums(GF(5))) # needs sage.rings.finite_rings
107+
sage: FormalSum([(1, 2/3), (3, 2/3), (-5, 7)], parent=FormalSums(GF(5)))
108108
4*2/3
109109
110110
Notice below that the coefficient 5 doesn't get reduced modulo 5::
111111
112-
sage: FormalSum([(1, 2/3), (3, 2/3), (-5, 7)], parent=FormalSums(GF(5)), # needs sage.rings.finite_rings
112+
sage: FormalSum([(1, 2/3), (3, 2/3), (-5, 7)], parent=FormalSums(GF(5)),
113113
....: check=False)
114114
4*2/3 - 5*7
115115
@@ -312,7 +312,7 @@ class FormalSums(UniqueRepresentation, Module):
312312
Abelian Group of all Formal Finite Sums over Integer Ring
313313
sage: FormalSums(ZZ)
314314
Abelian Group of all Formal Finite Sums over Integer Ring
315-
sage: FormalSums(GF(7)) # needs sage.rings.finite_rings
315+
sage: FormalSums(GF(7))
316316
Abelian Group of all Formal Finite Sums over Finite Field of size 7
317317
sage: FormalSums(ZZ[sqrt(2)]) # needs sage.rings.number_field sage.symbolic
318318
Abelian Group of all Formal Finite Sums over Order in Number Field in sqrt2
@@ -343,9 +343,9 @@ def _repr_(self):
343343
"""
344344
EXAMPLES::
345345
346-
sage: FormalSums(GF(7)) # needs sage.rings.finite_rings
346+
sage: FormalSums(GF(7))
347347
Abelian Group of all Formal Finite Sums over Finite Field of size 7
348-
sage: FormalSums(GF(7))._repr_() # needs sage.rings.finite_rings
348+
sage: FormalSums(GF(7))._repr_()
349349
'Abelian Group of all Formal Finite Sums over Finite Field of size 7'
350350
"""
351351
return "Abelian Group of all Formal Finite Sums over %s"%self.base_ring()
@@ -405,12 +405,12 @@ def base_extend(self, R):
405405
"""
406406
EXAMPLES::
407407
408-
sage: F7 = FormalSums(ZZ).base_extend(GF(7)); F7 # needs sage.rings.finite_rings
408+
sage: F7 = FormalSums(ZZ).base_extend(GF(7)); F7
409409
Abelian Group of all Formal Finite Sums over Finite Field of size 7
410410
411411
The following tests against a bug that was fixed at :trac:`18795`::
412412
413-
sage: isinstance(F7, F7.category().parent_class) # needs sage.rings.finite_rings
413+
sage: isinstance(F7, F7.category().parent_class)
414414
True
415415
"""
416416
if self.base_ring().has_coerce_map_from(R):

src/sage/structure/nonexact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
sage: R.<x> = PowerSeriesRing(QQ)
1010
sage: R.default_prec()
1111
20
12-
sage: cos(x) # needs sage.symbolic
12+
sage: cos(x)
1313
1 - 1/2*x^2 + 1/24*x^4 - 1/720*x^6 + 1/40320*x^8 - 1/3628800*x^10 +
1414
1/479001600*x^12 - 1/87178291200*x^14 + 1/20922789888000*x^16 -
1515
1/6402373705728000*x^18 + O(x^20)
@@ -19,7 +19,7 @@
1919
sage: R.<x> = PowerSeriesRing(QQ, default_prec=10)
2020
sage: R.default_prec()
2121
10
22-
sage: cos(x) # needs sage.symbolic
22+
sage: cos(x)
2323
1 - 1/2*x^2 + 1/24*x^4 - 1/720*x^6 + 1/40320*x^8 + O(x^10)
2424
2525
.. NOTE::

src/sage/structure/parent.pyx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,16 +1873,17 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
18731873
18741874
EXAMPLES::
18751875
1876+
sage: # needs sage.rings.number_field
18761877
sage: x = polygen(ZZ, 'x')
1877-
sage: K.<a> = NumberField(x^3 + x^2 + 1, embedding=1) # needs sage.rings.number_field
1878-
sage: K.coerce_embedding() # needs sage.rings.number_field
1878+
sage: K.<a> = NumberField(x^3 + x^2 + 1, embedding=1)
1879+
sage: K.coerce_embedding()
18791880
Generic morphism:
18801881
From: Number Field in a with defining polynomial x^3 + x^2 + 1
18811882
with a = -1.465571231876768?
18821883
To: Real Lazy Field
18831884
Defn: a -> -1.465571231876768?
1884-
sage: K.<a> = NumberField(x^3 + x^2 + 1, embedding=CC.gen()) # needs sage.rings.number_field
1885-
sage: K.coerce_embedding() # needs sage.rings.number_field
1885+
sage: K.<a> = NumberField(x^3 + x^2 + 1, embedding=CC.gen())
1886+
sage: K.coerce_embedding()
18861887
Generic morphism:
18871888
From: Number Field in a with defining polynomial x^3 + x^2 + 1
18881889
with a = 0.2327856159383841? + 0.7925519925154479?*I
@@ -2299,19 +2300,20 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
22992300
23002301
Another test::
23012302
2303+
sage: # needs sage.rings.number_field
23022304
sage: x = polygen(ZZ, 'x')
2303-
sage: K = NumberField([x^2 - 2, x^2 - 3], 'a,b') # needs sage.rings.number_field
2304-
sage: M = K.absolute_field('c') # needs sage.rings.number_field
2305-
sage: M_to_K, K_to_M = M.structure() # needs sage.rings.number_field
2306-
sage: M.register_coercion(K_to_M) # needs sage.rings.number_field
2307-
sage: K.register_coercion(M_to_K) # needs sage.rings.number_field
2308-
sage: phi = M.coerce_map_from(QQ) # needs sage.rings.number_field
2309-
sage: p = QQ.random_element() # needs sage.rings.number_field
2310-
sage: c = phi(p) - p; c # needs sage.rings.number_field
2305+
sage: K = NumberField([x^2 - 2, x^2 - 3], 'a,b')
2306+
sage: M = K.absolute_field('c')
2307+
sage: M_to_K, K_to_M = M.structure()
2308+
sage: M.register_coercion(K_to_M)
2309+
sage: K.register_coercion(M_to_K)
2310+
sage: phi = M.coerce_map_from(QQ)
2311+
sage: p = QQ.random_element()
2312+
sage: c = phi(p) - p; c
23112313
0
2312-
sage: c.parent() is M # needs sage.rings.number_field
2314+
sage: c.parent() is M
23132315
True
2314-
sage: K.coerce_map_from(QQ) # needs sage.rings.number_field
2316+
sage: K.coerce_map_from(QQ)
23152317
Coercion map:
23162318
From: Rational Field
23172319
To: Number Field in a with defining polynomial x^2 - 2 over its base field
@@ -2851,7 +2853,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
28512853
[False, False]
28522854
sage: [R._is_numerical() for R in [RBF, CBF]] # needs sage.libs.flint
28532855
[False, False]
2854-
sage: [R._is_numerical() for R in [RIF, CIF]]
2856+
sage: [R._is_numerical() for R in [RIF, CIF]] # needs sage.rings.real_interval_field
28552857
[False, False]
28562858
"""
28572859
try:
@@ -2862,8 +2864,15 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
28622864
else:
28632865
return ComplexField(mpfr_prec_min()).has_coerce_map_from(self)
28642866

2865-
from sage.rings.real_double import CDF
2866-
return CDF.has_coerce_map_from(self)
2867+
try:
2868+
from sage.rings.complex_double import CDF
2869+
except ImportError:
2870+
pass
2871+
else:
2872+
return CDF.has_coerce_map_from(self)
2873+
2874+
from sage.rings.real_double import RDF
2875+
return RDF.has_coerce_map_from(self)
28672876

28682877
@cached_method
28692878
def _is_real_numerical(self):

0 commit comments

Comments
 (0)