Skip to content

Commit defa42e

Browse files
author
Matthias Koeppe
committed
src/sage/rings/polynomial/polynomial_element.pyx: Doctest cosmetics, more block tags
1 parent 18ae0e9 commit defa42e

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,11 @@ cdef class Polynomial(CommutativePolynomial):
565565
tuple containing the values to be substituted, though it is
566566
perhaps more natural to just unpack the list::
567567
568-
sage: f([2]) # calling with a list
568+
sage: f([2]) # calling with a list
569569
3*x + 4
570-
sage: f((2,)) # calling with a tuple
570+
sage: f((2,)) # calling with a tuple
571571
3*x + 4
572-
sage: f(*[2]) # unpacking the list to call normally
572+
sage: f(*[2]) # unpacking the list to call normally
573573
3*x + 4
574574
575575
The following results in an element of the symbolic ring. ::
@@ -710,11 +710,12 @@ cdef class Polynomial(CommutativePolynomial):
710710
711711
These were drastically slower prior to :trac:`33165`::
712712
713-
sage: R.<x> = GF(31337)[] # needs sage.rings.finite_rings
713+
sage: # needs sage.rings.finite_rings
714+
sage: R.<x> = GF(31337)[]
714715
sage: f = R(list(range(100, 201)))
715716
sage: g = R(list(range(1, 1001)))
716-
sage: S.<y> = R.quotient(f) # needs sage.rings.finite_rings
717-
sage: g(y) # needs sage.rings.finite_rings
717+
sage: S.<y> = R.quotient(f)
718+
sage: g(y)
718719
22537*y^99 + 4686*y^98 + 13285*y^97 + 4216*y^96 + ... + 6389*y^3 + 30062*y^2 + 13755*y + 11875
719720
720721
::
@@ -1300,7 +1301,7 @@ cdef class Polynomial(CommutativePolynomial):
13001301
Defn: x |--> 5
13011302
sage: f(x)
13021303
5
1303-
sage: f(x^2 + 3) # indirect doctest
1304+
sage: f(x^2 + 3) # indirect doctest
13041305
28
13051306
13061307
sage: # needs sage.rings.number_field
@@ -1383,7 +1384,7 @@ cdef class Polynomial(CommutativePolynomial):
13831384
0.6324555320336758*I
13841385
sage: CC(c)
13851386
0.632455532033676*I
1386-
sage: CBF(c) # abs tol 1e-16 # needs sage.libs.flint
1387+
sage: CBF(c) # abs tol 1e-16 # needs sage.libs.flint
13871388
[0.6324555320336759 +/- 3.38e-17]*I
13881389
sage: CIF(c)
13891390
0.6324555320336758?*I
@@ -2455,12 +2456,13 @@ cdef class Polynomial(CommutativePolynomial):
24552456
24562457
Check that the algorithm used is indeed correct::
24572458
2459+
sage: # needs sage.rings.finite_rings
24582460
sage: from sage.arith.power import generic_power
2459-
sage: R1 = PolynomialRing(GF(8,'a'), 'x') # needs sage.rings.finite_rings
2460-
sage: R2 = PolynomialRing(GF(9,'b'), 'x', sparse=True) # needs sage.rings.finite_rings
2461+
sage: R1 = PolynomialRing(GF(8,'a'), 'x')
2462+
sage: R2 = PolynomialRing(GF(9,'b'), 'x', sparse=True)
24612463
sage: R3 = PolynomialRing(R2, 'y')
24622464
sage: R4 = PolynomialRing(R1, 'y', sparse=True)
2463-
sage: for d in range(20,40): # long time # needs sage.rings.finite_rings
2465+
sage: for d in range(20,40): # long time
24642466
....: for R in [R1, R2, R3, R3]:
24652467
....: a = R.random_element()
24662468
....: assert a^d == generic_power(a, d)
@@ -2595,16 +2597,16 @@ cdef class Polynomial(CommutativePolynomial):
25952597
TESTS::
25962598
25972599
sage: x = polygen(QQ)
2598-
sage: (3*x-5).power_trunc(2^200, 0)
2600+
sage: (3*x - 5).power_trunc(2^200, 0)
25992601
0
26002602
sage: x.power_trunc(-1, 10)
26012603
Traceback (most recent call last):
26022604
...
26032605
ValueError: n must be a non-negative integer
26042606
sage: R.<y> = QQ['x']
2605-
sage: y.power_trunc(2**32-1, 2)
2607+
sage: y.power_trunc(2**32 - 1, 2)
26062608
0
2607-
sage: y.power_trunc(2**64-1, 2)
2609+
sage: y.power_trunc(2**64 - 1, 2)
26082610
0
26092611
"""
26102612
cdef Integer ZZn = ZZ(n)
@@ -4256,7 +4258,7 @@ cdef class Polynomial(CommutativePolynomial):
42564258
* (x + 0.9999908759550227 - 1.0000069659624138*I)
42574259
* (x + 0.9999985293216753 - 0.9999886153831807*I)
42584260
* (x + 1.0000105947233 - 1.0000044186544053*I)
4259-
sage: [f(t[0][0]).abs() for t in F] # abs tol 1e-13
4261+
sage: [f(t[0][0]).abs() for t in F] # abs tol 1e-13
42604262
[1.979365054e-14, 1.97936298566e-14, 1.97936990747e-14,
42614263
3.6812407475e-14, 3.65211563729e-14, 3.65220890052e-14]
42624264
@@ -4398,20 +4400,22 @@ cdef class Polynomial(CommutativePolynomial):
43984400
43994401
Test that :trac:`10279` is fixed::
44004402
4403+
sage: # needs sage.rings.number_field
44014404
sage: R.<t> = PolynomialRing(QQ)
4402-
sage: K.<a> = NumberField(t^4 - t^2 + 1) # needs sage.rings.number_field
4403-
sage: pol = t^3 + (-4*a^3 + 2*a)*t^2 - 11/3*a^2*t + 2/3*a^3 - 4/3*a # needs sage.rings.number_field
4404-
sage: pol.factor() # needs sage.rings.number_field
4405+
sage: K.<a> = NumberField(t^4 - t^2 + 1)
4406+
sage: pol = t^3 + (-4*a^3 + 2*a)*t^2 - 11/3*a^2*t + 2/3*a^3 - 4/3*a
4407+
sage: pol.factor()
44054408
(t - 2*a^3 + a) * (t - 4/3*a^3 + 2/3*a) * (t - 2/3*a^3 + 1/3*a)
44064409
44074410
Test that this factorization really uses ``nffactor()`` internally::
44084411
4409-
sage: pari.default("debug", 3) # needs sage.libs.pari
4410-
sage: F = pol.factor() # needs sage.rings.number_field
4412+
sage: # needs sage.libs.pari sage.rings.number_field
4413+
sage: pari.default("debug", 3)
4414+
sage: F = pol.factor()
44114415
<BLANKLINE>
44124416
Entering nffactor:
44134417
...
4414-
sage: pari.default("debug", 0) # needs sage.libs.pari
4418+
sage: pari.default("debug", 0)
44154419
44164420
Test that :trac:`10369` is fixed::
44174421
@@ -9827,6 +9831,7 @@ cdef class Polynomial(CommutativePolynomial):
98279831
A generic implementation is available, which relies on gcd
98289832
computations::
98299833
9834+
sage: # needs sage.libs.pari
98309835
sage: R.<x> = ZZ[]
98319836
sage: (2*x).is_squarefree() # needs sage.libs.pari
98329837
True
@@ -9937,9 +9942,9 @@ cdef class Polynomial(CommutativePolynomial):
99379942
EXAMPLES::
99389943
99399944
sage: R.<x> = QQbar[] # needs sage.rings.number_field
9940-
sage: (x^2*(x + 1)).is_squarefree() # indirect doctest # needs sage.rings.number_field
9945+
sage: (x^2*(x + 1)).is_squarefree() # indirect doctest # needs sage.rings.number_field
99419946
False
9942-
sage: (x*(x+1)).is_squarefree() # indirect doctest # needs sage.rings.number_field
9947+
sage: (x*(x+1)).is_squarefree() # indirect doctest # needs sage.rings.number_field
99439948
True
99449949
99459950
"""
@@ -10162,23 +10167,25 @@ cdef class Polynomial(CommutativePolynomial):
1016210167
1016310168
EXAMPLES::
1016410169
10165-
sage: R.<x> = SR[] # needs sage.symbolic
10166-
sage: f = (1+I)*x^2 + 3*x - I # needs sage.symbolic
10167-
sage: f.map_coefficients(lambda z: z.conjugate()) # needs sage.symbolic
10168-
(-I + 1)*x^2 + 3*x + I
1016910170
sage: R.<x> = ZZ[]
1017010171
sage: f = x^2 + 2
1017110172
sage: f.map_coefficients(lambda a: a + 42)
1017210173
43*x^2 + 44
10173-
sage: R.<x> = PolynomialRing(SR, sparse=True) # needs sage.symbolic
10174-
sage: f = (1+I)*x^(2^32) - I # needs sage.symbolic
10175-
sage: f.map_coefficients(lambda z: z.conjugate()) # needs sage.symbolic
10176-
(-I + 1)*x^4294967296 + I
1017710174
sage: R.<x> = PolynomialRing(ZZ, sparse=True)
1017810175
sage: f = x^(2^32) + 2
1017910176
sage: f.map_coefficients(lambda a: a + 42)
1018010177
43*x^4294967296 + 44
1018110178
10179+
sage: # needs sage.symbolic
10180+
sage: R.<x> = SR[]
10181+
sage: f = (1+I)*x^2 + 3*x - I
10182+
sage: f.map_coefficients(lambda z: z.conjugate())
10183+
(-I + 1)*x^2 + 3*x + I
10184+
sage: R.<x> = PolynomialRing(SR, sparse=True)
10185+
sage: f = (1+I)*x^(2^32) - I
10186+
sage: f.map_coefficients(lambda z: z.conjugate())
10187+
(-I + 1)*x^4294967296 + I
10188+
1018210189
Examples with different base ring::
1018310190
1018410191
sage: R.<x> = ZZ[]
@@ -12453,7 +12460,7 @@ cdef class ConstantPolynomialSection(Map):
1245312460
Generic map:
1245412461
From: Univariate Polynomial Ring in x over Rational Field
1245512462
To: Rational Field
12456-
sage: m(x-x+1/2) # implicit
12463+
sage: m(x-x+1/2) # implicit
1245712464
1/2
1245812465
sage: m(x-x)
1245912466
0
@@ -12598,7 +12605,7 @@ cdef class PolynomialBaseringInjection(Morphism):
1259812605
Polynomial base injection morphism:
1259912606
From: Integer Ring
1260012607
To: Univariate Polynomial Ring in x over Integer Ring
12601-
sage: m(2) # indirect doctest
12608+
sage: m(2) # indirect doctest
1260212609
2
1260312610
sage: parent(m(2))
1260412611
Univariate Polynomial Ring in x over Integer Ring
@@ -12649,7 +12656,7 @@ cdef class PolynomialBaseringInjection(Morphism):
1264912656
1265012657
Check that :trac:`23203` has been resolved::
1265112658
12652-
sage: R.is_subring(S) # indirect doctest
12659+
sage: R.is_subring(S) # indirect doctest
1265312660
True
1265412661
1265512662
"""

0 commit comments

Comments
 (0)