Skip to content

Commit 18ae0e9

Browse files
author
Matthias Koeppe
committed
sage.rings.polynomial: Fix up # needs, doctest cosmetics
1 parent ae81a48 commit 18ae0e9

File tree

6 files changed

+35
-53
lines changed

6 files changed

+35
-53
lines changed

src/sage/rings/polynomial/laurent_polynomial_ring_base.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,16 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None):
391391
"""
392392
EXAMPLES::
393393
394+
sage: # needs sage.rings.number_field
394395
sage: T.<t> = ZZ[]
395-
sage: K.<i> = NumberField(t^2 + 1) # needs sage.rings.number_field
396-
sage: L.<x,y> = LaurentPolynomialRing(K) # needs sage.rings.number_field
397-
sage: L._is_valid_homomorphism_(K, (K(1/2), K(3/2))) # needs sage.rings.number_field
396+
sage: K.<i> = NumberField(t^2 + 1)
397+
sage: L.<x,y> = LaurentPolynomialRing(K)
398+
sage: L._is_valid_homomorphism_(K, (K(1/2), K(3/2)))
398399
True
399400
sage: Q5 = Qp(5); i5 = Q5(-1).sqrt() # needs sage.rings.padics
400-
sage: L._is_valid_homomorphism_(Q5, (Q5(1/2), Q5(3/2))) # no coercion # needs sage.rings.number_field sage.rings.padics
401+
sage: L._is_valid_homomorphism_(Q5, (Q5(1/2), Q5(3/2))) # no coercion # needs sage.rings.padics
401402
False
402-
sage: L._is_valid_homomorphism_(Q5, (Q5(1/2), Q5(3/2)), base_map=K.hom([i5])) # needs sage.rings.number_field sage.rings.padics
403+
sage: L._is_valid_homomorphism_(Q5, (Q5(1/2), Q5(3/2)), base_map=K.hom([i5])) # needs sage.rings.padics
403404
True
404405
"""
405406
if base_map is None and not codomain.has_coerce_map_from(self.base_ring()):

src/sage/rings/polynomial/multi_polynomial.pyx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ cdef class MPolynomial(CommutativePolynomial):
4141
TESTS::
4242
4343
sage: # needs sage.rings.real_mpfr
44-
sage: ZZ(RR['x,y'](0)) # indirect doctest
44+
sage: ZZ(RR['x,y'](0)) # indirect doctest
4545
0
4646
sage: ZZ(RR['x,y'](0.5))
4747
Traceback (most recent call last):
@@ -53,15 +53,15 @@ cdef class MPolynomial(CommutativePolynomial):
5353
TypeError: unable to convert non-constant polynomial x to Integer Ring
5454
5555
sage: # needs sage.rings.real_mpfr
56-
sage: RR(RR['x,y'](0)) # indirect doctest
56+
sage: RR(RR['x,y'](0)) # indirect doctest
5757
0.000000000000000
5858
sage: RR(ZZ['x,y'].gen(0))
5959
Traceback (most recent call last):
6060
...
6161
TypeError: unable to convert non-constant polynomial x to Real Field with 53 bits of precision
6262
6363
sage: # needs sage.rings.real_mpfr
64-
sage: CC(RR['x,y'](0)) # indirect doctest
64+
sage: CC(RR['x,y'](0)) # indirect doctest
6565
0.000000000000000
6666
sage: CC(ZZ['x,y'].gen(0))
6767
Traceback (most recent call last):
@@ -77,27 +77,26 @@ cdef class MPolynomial(CommutativePolynomial):
7777
TypeError: unable to convert non-constant polynomial x to Real Double Field
7878
7979
sage: # needs sage.rings.real_mpfr
80-
sage: CDF(RR['x,y'](0)) # indirect doctest
80+
sage: CDF(RR['x,y'](0)) # indirect doctest
8181
0.0
8282
sage: CDF(ZZ['x,y'].gen(0))
8383
Traceback (most recent call last):
8484
...
8585
TypeError: unable to convert non-constant polynomial x to Complex Double Field
8686
87-
sage: # needs sage.rings.real_mpfr
87+
sage: # needs sage.libs.flint sage.rings.real_mpfr
8888
sage: a = RR['x,y'](1)
89-
sage: RBF(a) # needs sage.libs.flint
89+
sage: RBF(a)
9090
1.000000000000000
9191
sage: RIF(a)
9292
1
93-
sage: CBF(a) # needs sage.libs.flint
93+
sage: CBF(a)
9494
1.000000000000000
9595
sage: CIF(a)
9696
1
97-
98-
sage: CBF(RR['x,y'](1)) # indirect doctest # needs sage.libs.flint
97+
sage: CBF(RR['x,y'](1)) # indirect doctest
9998
1.000000000000000
100-
sage: CBF(ZZ['x,y'].gen(0)) # needs sage.libs.flint
99+
sage: CBF(ZZ['x,y'].gen(0))
101100
Traceback (most recent call last):
102101
...
103102
TypeError: unable to convert non-constant polynomial x to Complex ball field with 53 bits of precision
@@ -132,7 +131,7 @@ cdef class MPolynomial(CommutativePolynomial):
132131
sage: type(RR['x, y'](0))
133132
<class 'sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict'>
134133
135-
sage: int(RR['x,y'](0)) # indirect doctest
134+
sage: int(RR['x,y'](0)) # indirect doctest
136135
0
137136
sage: int(RR['x,y'](10))
138137
10
@@ -141,7 +140,7 @@ cdef class MPolynomial(CommutativePolynomial):
141140
...
142141
TypeError: unable to convert non-constant polynomial x to <class 'int'>
143142
144-
sage: ZZ(RR['x,y'](0)) # indirect doctest
143+
sage: ZZ(RR['x,y'](0)) # indirect doctest
145144
0
146145
sage: ZZ(RR['x,y'](0.5))
147146
Traceback (most recent call last):
@@ -158,7 +157,7 @@ cdef class MPolynomial(CommutativePolynomial):
158157
r"""
159158
TESTS::
160159
161-
sage: float(RR['x,y'](0)) # indirect doctest
160+
sage: float(RR['x,y'](0)) # indirect doctest
162161
0.0
163162
sage: float(ZZ['x,y'].gen(0))
164163
Traceback (most recent call last):
@@ -171,7 +170,7 @@ cdef class MPolynomial(CommutativePolynomial):
171170
r"""
172171
TESTS::
173172
174-
sage: QQ(RR['x,y'](0.5)) # indirect doctest
173+
sage: QQ(RR['x,y'](0.5)) # indirect doctest
175174
1/2
176175
sage: QQ(RR['x,y'].gen(0))
177176
Traceback (most recent call last):
@@ -2438,7 +2437,7 @@ cdef class MPolynomial(CommutativePolynomial):
24382437
sage: R.<x,y> = PolynomialRing(RR)
24392438
sage: F = (217.992172373276*x^3 + 96023.1505442490*x^2*y
24402439
....: + 1.40987971253579e7*x*y^2 + 6.90016027113216e8*y^3)
2441-
sage: F.reduced_form(smallest_coeffs=False) # tol 1e-8 # needs sage.modules sage.rings.complex_interval_field
2440+
sage: F.reduced_form(smallest_coeffs=False) # tol 1e-8 # needs sage.modules sage.rings.complex_interval_field
24422441
(
24432442
-39.5673942565918*x^3 + 111.874026298523*x^2*y
24442443
+ 231.052762985229*x*y^2 - 138.380829811096*y^3,
@@ -2481,7 +2480,7 @@ cdef class MPolynomial(CommutativePolynomial):
24812480
emb = kwds.get('emb', None)
24822481

24832482
# getting a numerical approximation of the roots of our polynomial
2484-
CF = ComplexIntervalField(prec=prec) # keeps trac of our precision error
2483+
CF = ComplexIntervalField(prec=prec) # keeps trac of our precision error
24852484
RF = RealField(prec=prec)
24862485
R = self.parent()
24872486
x,y = R.gens()

src/sage/rings/polynomial/ore_polynomial_element.pyx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,13 +1406,12 @@ cdef class OrePolynomial(AlgebraElement):
14061406
sage: k.<a> = GF(7^5)
14071407
sage: Frob = k.frobenius_endomorphism(3)
14081408
sage: S.<x> = k['x', Frob]
1409-
sage: # needs sage.rings.finite_rings
1410-
sage: D = S.random_element(degree=2) # needs sage.misc.cython
1411-
sage: P = D * S.random_element(degree=2) # needs sage.misc.cython
1412-
sage: Q = D * S.random_element(degree=2) # needs sage.misc.cython
1409+
sage: D = S.random_element(degree=2)
1410+
sage: P = D * S.random_element(degree=2)
1411+
sage: Q = D * S.random_element(degree=2)
14131412
sage: L = P.right_lcm(Q)
1414-
sage: U = right_lcm_cofactor(P, Q) # needs sage.misc.cython
1415-
sage: (P*U).left_monic() == L # needs sage.misc.cython
1413+
sage: U = right_lcm_cofactor(P, Q)
1414+
sage: (P*U).left_monic() == L
14161415
True
14171416
"""
14181417
cdef OrePolynomial Q, R, T

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6790,7 +6790,7 @@ cdef class Polynomial(CommutativePolynomial):
67906790
67916791
TESTS::
67926792
6793-
saeg: # needs sage.libs.giap
6793+
sage: # needs sage.libs.giac
67946794
sage: R.<x> = GF(101)['e,i'][]
67956795
sage: f = R('e*i') * x + x^2
67966796
sage: f._giac_init_()
@@ -10263,16 +10263,16 @@ cdef class Polynomial(CommutativePolynomial):
1026310263
1026410264
Some more tests::
1026510265
10266-
saeg: # needs sage.libs.pari
10267-
sage: f = x^16 + x^14 - x^10 + x^8 - x^6 + x^2 + 1 # needs sage.libs.pari
10268-
sage: f.is_cyclotomic(algorithm="pari") # needs sage.libs.pari
10266+
sage: # needs sage.libs.pari
10267+
sage: f = x^16 + x^14 - x^10 + x^8 - x^6 + x^2 + 1
10268+
sage: f.is_cyclotomic(algorithm="pari")
1026910269
False
10270-
sage: f.is_cyclotomic(algorithm="sage") # needs sage.libs.pari
10270+
sage: f.is_cyclotomic(algorithm="sage")
1027110271
False
10272-
sage: g = x^16 + x^14 - x^10 - x^8 - x^6 + x^2 + 1 # needs sage.libs.pari
10273-
sage: g.is_cyclotomic(algorithm="pari") # needs sage.libs.pari
10272+
sage: g = x^16 + x^14 - x^10 - x^8 - x^6 + x^2 + 1
10273+
sage: g.is_cyclotomic(algorithm="pari")
1027410274
True
10275-
sage: g.is_cyclotomic(algorithm="sage") # needs sage.libs.pari
10275+
sage: g.is_cyclotomic(algorithm="sage")
1027610276
True
1027710277
1027810278
sage: y = polygen(QQ)

src/sage/rings/polynomial/polynomial_quotient_ring.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
EXAMPLES::
66
7-
sage:
87
sage: R.<x> = QQ[]
98
sage: S = R.quotient(x**3 - 3*x + 1, 'alpha')
109
sage: S.gen()**2 in S
@@ -80,7 +79,6 @@ class PolynomialQuotientRingFactory(UniqueFactory):
8079
We create the quotient ring `\ZZ[x]/(x^3+7)`, and
8180
demonstrate many basic functions with it::
8281
83-
sage:
8482
sage: Z = IntegerRing()
8583
sage: R = PolynomialRing(Z, 'x'); x = R.gen()
8684
sage: S = R.quotient(x^3 + 7, 'a'); a = S.gen()
@@ -131,7 +129,6 @@ class PolynomialQuotientRingFactory(UniqueFactory):
131129
Next we create a number field, but viewed as a quotient of a
132130
polynomial ring over `\QQ`::
133131
134-
sage:
135132
sage: R = PolynomialRing(RationalField(), 'x'); x = R.gen()
136133
sage: S = R.quotient(x^3 + 2*x - 5, 'a'); S
137134
Univariate Quotient Polynomial Ring in a over Rational Field
@@ -198,7 +195,6 @@ def create_key(self, ring, polynomial, names=None):
198195
199196
Consequently, you get two distinct objects::
200197
201-
sage:
202198
sage: S = PolynomialQuotientRing(R, x + 1); S
203199
Univariate Quotient Polynomial Ring in xbar over Rational Field with modulus x + 1
204200
sage: T = PolynomialQuotientRing(R, 2*x + 2); T
@@ -344,7 +340,6 @@ class of the category, and store the current class of the quotient
344340
We try to find out whether `Q` is a field. Indeed it is, and thus its category,
345341
including its class and element class, is changed accordingly::
346342
347-
sage:
348343
sage: Q in Fields()
349344
True
350345
sage: Q.category()
@@ -503,7 +498,6 @@ def _element_constructor_(self, x):
503498
when the given string suggests an element of the cover ring or the base
504499
ring::
505500
506-
sage:
507501
sage: a = Q1('x'); a
508502
xbar
509503
sage: a.parent() is Q1
@@ -516,7 +510,6 @@ def _element_constructor_(self, x):
516510
Conversion may lift an element of one quotient ring to the base ring of
517511
another quotient ring::
518512
519-
sage:
520513
sage: R.<y> = P[]
521514
sage: Q3 = R.quo([(y^2+1)])
522515
sage: Q3(Q1.gen())
@@ -666,7 +659,6 @@ def lift(self, x):
666659
667660
EXAMPLES::
668661
669-
sage:
670662
sage: P.<x> = QQ[]
671663
sage: Q = P.quotient(x^2 + 2)
672664
sage: Q.lift(Q.0^3)
@@ -685,7 +677,6 @@ def __eq__(self, other):
685677
686678
EXAMPLES::
687679
688-
sage:
689680
sage: Rx.<x> = PolynomialRing(QQ)
690681
sage: Ry.<y> = PolynomialRing(QQ)
691682
sage: Rx == Ry
@@ -711,7 +702,6 @@ def __ne__(self, other):
711702
712703
EXAMPLES::
713704
714-
sage:
715705
sage: Rx.<x> = PolynomialRing(QQ)
716706
sage: Ry.<y> = PolynomialRing(QQ)
717707
sage: Rx != Ry
@@ -734,7 +724,6 @@ def __hash__(self):
734724
735725
EXAMPLES::
736726
737-
sage:
738727
sage: Rx.<x> = PolynomialRing(QQ)
739728
sage: Ry.<y> = PolynomialRing(QQ)
740729
sage: hash(Rx) == hash(Ry)
@@ -1003,7 +992,6 @@ def discriminant(self, v=None):
1003992
1004993
EXAMPLES::
1005994
1006-
sage:
1007995
sage: R.<x> = PolynomialRing(QQ)
1008996
sage: S = R.quotient(x^3 + x^2 + x + 1)
1009997
sage: S.discriminant()
@@ -1051,7 +1039,6 @@ def is_field(self, proof=True):
10511039
10521040
EXAMPLES::
10531041
1054-
sage:
10551042
sage: R.<z> = PolynomialRing(ZZ)
10561043
sage: S = R.quo(z^2 - 2)
10571044
sage: S.is_field()
@@ -2279,7 +2266,6 @@ def _richcmp_(self, other, op):
22792266
22802267
EXAMPLES::
22812268
2282-
sage:
22832269
sage: R.<x> = ZZ[]
22842270
sage: S.<x> = ZZ[]
22852271
sage: f = S.quo(x).coerce_map_from(R.quo(x^2))
@@ -2299,7 +2285,6 @@ class PolynomialQuotientRing_domain(PolynomialQuotientRing_generic, IntegralDoma
22992285
"""
23002286
EXAMPLES::
23012287
2302-
sage:
23032288
sage: R.<x> = PolynomialRing(ZZ)
23042289
sage: S.<xbar> = R.quotient(x^2 + 1)
23052290
sage: S
@@ -2327,7 +2312,6 @@ def __init__(self, ring, polynomial, name=None, category=None):
23272312
23282313
Check that :trac:`29017` is fixed::
23292314
2330-
sage:
23312315
sage: R.<x> = ZZ[]
23322316
sage: Q = R.quo(x - 1)
23332317
sage: H = R.Hom(Q)

src/sage/rings/polynomial/term_order.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,8 +1827,7 @@ def macaulay2_str(self):
18271827
18281828
EXAMPLES::
18291829
1830-
sage: P = PolynomialRing(GF(127), 8, names='x',
1831-
....: order='degrevlex(3),lex(5)')
1830+
sage: P = PolynomialRing(GF(127), 8, names='x', order='degrevlex(3),lex(5)')
18321831
sage: T = P.term_order()
18331832
sage: T.macaulay2_str()
18341833
'{GRevLex => 3,Lex => 5}'

0 commit comments

Comments
 (0)