Skip to content

Commit 501ed25

Browse files
author
Release Manager
committed
gh-37623: src/sage/rings: Doctest cosmetics <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37623 Reported by: Matthias Köppe Reviewer(s): David Coudert
2 parents ef51da6 + 92726b7 commit 501ed25

File tree

11 files changed

+199
-157
lines changed

11 files changed

+199
-157
lines changed

src/sage/rings/complex_conversion.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cdef class CCtoCDF(Map):
99
"""
1010
EXAMPLES::
1111
sage: from sage.rings.complex_conversion import CCtoCDF
12-
sage: f = CCtoCDF(CC, CDF) # indirect doctest
12+
sage: f = CCtoCDF(CC, CDF) # indirect doctest
1313
sage: f(CC.0)
1414
1.0*I
1515
sage: f(exp(pi*CC.0/4)) # needs sage.symbolic

src/sage/rings/complex_mpfr.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ class ComplexField_class(sage.rings.abc.ComplexField):
444444
sage: CC.gen() + QQ.extension(x^2 + 1, 'I', embedding=None).gen() # needs sage.rings.number_field
445445
Traceback (most recent call last):
446446
...
447-
TypeError: unsupported operand parent(s) for +: 'Complex Field with 53 bits of precision' and 'Number Field in I with defining polynomial x^2 + 1'
447+
TypeError: unsupported operand parent(s) for +:
448+
'Complex Field with 53 bits of precision' and
449+
'Number Field in I with defining polynomial x^2 + 1'
448450
449451
In the absence of arguments we return zero::
450452

src/sage/rings/finite_rings/residue_field_givaro.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ResidueFiniteField_givaro(ResidueField_generic, FiniteField_givaro):
123123
124124
sage: R.<t> = GF(3)[]; P = R.ideal(t^4 - t^3 + t + 1); k.<a> = P.residue_field()
125125
sage: V = k.vector_space(map=False); v = V([0,1,2,3])
126-
sage: k(v) # indirect doctest
126+
sage: k(v) # indirect doctest
127127
2*a^2 + a
128128
"""
129129
try:

src/sage/rings/function_field/function_field_polymod.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -739,46 +739,50 @@ def free_module(self, base=None, basis=None, map=True):
739739
740740
We convert an element of the vector space back to the function field::
741741
742-
sage: from_V(V.1) # needs sage.modules
742+
sage: from_V(V.1) # needs sage.modules
743743
y
744744
745745
We define an interesting element of the function field::
746746
747-
sage: a = 1/L.0; a # needs sage.modules
747+
sage: a = 1/L.0; a # needs sage.modules
748748
(x/(x^4 + 1))*y^4 - 2*x^2/(x^4 + 1)
749749
750750
We convert it to the vector space, and get a vector over the base field::
751751
752-
sage: to_V(a) # needs sage.modules
752+
sage: to_V(a) # needs sage.modules
753753
(-2*x^2/(x^4 + 1), 0, 0, 0, x/(x^4 + 1))
754754
755755
We convert to and back, and get the same element::
756756
757-
sage: from_V(to_V(a)) == a # needs sage.modules
757+
sage: from_V(to_V(a)) == a # needs sage.modules
758758
True
759759
760760
In the other direction::
761761
762-
sage: v = x*V.0 + (1/x)*V.1 # needs sage.modules
763-
sage: to_V(from_V(v)) == v # needs sage.modules
762+
sage: v = x*V.0 + (1/x)*V.1 # needs sage.modules
763+
sage: to_V(from_V(v)) == v # needs sage.modules
764764
True
765765
766766
And we show how it works over an extension of an extension field::
767767
768768
sage: R2.<z> = L[]; M.<z> = L.extension(z^2 - y)
769-
sage: M.free_module() # needs sage.modules
770-
(Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x, Isomorphism:
769+
sage: M.free_module() # needs sage.modules
770+
(Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x,
771+
Isomorphism:
771772
From: Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x
772-
To: Function field in z defined by z^2 - y, Isomorphism:
773+
To: Function field in z defined by z^2 - y,
774+
Isomorphism:
773775
From: Function field in z defined by z^2 - y
774776
To: Vector space of dimension 2 over Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x)
775777
776778
We can also get the vector space of ``M`` over ``K``::
777779
778-
sage: M.free_module(K) # needs sage.modules
779-
(Vector space of dimension 10 over Rational function field in x over Rational Field, Isomorphism:
780+
sage: M.free_module(K) # needs sage.modules
781+
(Vector space of dimension 10 over Rational function field in x over Rational Field,
782+
Isomorphism:
780783
From: Vector space of dimension 10 over Rational function field in x over Rational Field
781-
To: Function field in z defined by z^2 - y, Isomorphism:
784+
To: Function field in z defined by z^2 - y,
785+
Isomorphism:
782786
From: Function field in z defined by z^2 - y
783787
To: Vector space of dimension 10 over Rational function field in x over Rational Field)
784788
@@ -1271,10 +1275,12 @@ def simple_model(self, name=None):
12711275
sage: L.<y> = K.extension(y^2 - x); R.<z> = L[]
12721276
sage: M.<z> = L.extension(z^2 - y)
12731277
sage: M.simple_model()
1274-
(Function field in z defined by z^4 + x, Function Field morphism:
1278+
(Function field in z defined by z^4 + x,
1279+
Function Field morphism:
12751280
From: Function field in z defined by z^4 + x
12761281
To: Function field in z defined by z^2 + y
1277-
Defn: z |--> z, Function Field morphism:
1282+
Defn: z |--> z,
1283+
Function Field morphism:
12781284
From: Function field in z defined by z^2 + y
12791285
To: Function field in z defined by z^4 + x
12801286
Defn: z |--> z
@@ -1444,7 +1450,8 @@ def separable_model(self, names=None):
14441450
sage: L.separable_model() # needs sage.rings.finite_rings
14451451
Traceback (most recent call last):
14461452
...
1447-
NotImplementedError: constructing a separable model is only implemented for function fields over a perfect constant base field
1453+
NotImplementedError: constructing a separable model is only implemented
1454+
for function fields over a perfect constant base field
14481455
14491456
TESTS:
14501457
@@ -1493,11 +1500,13 @@ def separable_model(self, names=None):
14931500
sage: R.<z> = L[]
14941501
sage: M.<z> = L.extension(z^3 - y)
14951502
sage: M.separable_model()
1496-
(Function field in z_ defined by z_ + x_^6, Function Field morphism:
1503+
(Function field in z_ defined by z_ + x_^6,
1504+
Function Field morphism:
14971505
From: Function field in z_ defined by z_ + x_^6
14981506
To: Function field in z defined by z^3 + y
14991507
Defn: z_ |--> x
1500-
x_ |--> z, Function Field morphism:
1508+
x_ |--> z,
1509+
Function Field morphism:
15011510
From: Function field in z defined by z^3 + y
15021511
To: Function field in z_ defined by z_ + x_^6
15031512
Defn: z |--> x_
@@ -1606,12 +1615,14 @@ def change_variable_name(self, name):
16061615
y |--> y
16071616
x |--> x)
16081617
sage: M.change_variable_name(('zz','yy'))
1609-
(Function field in zz defined by zz^2 - yy, Function Field morphism:
1618+
(Function field in zz defined by zz^2 - yy,
1619+
Function Field morphism:
16101620
From: Function field in zz defined by zz^2 - yy
16111621
To: Function field in z defined by z^2 - y
16121622
Defn: zz |--> z
16131623
yy |--> y
1614-
x |--> x, Function Field morphism:
1624+
x |--> x,
1625+
Function Field morphism:
16151626
From: Function field in z defined by z^2 - y
16161627
To: Function field in zz defined by zz^2 - yy
16171628
Defn: z |--> zz
@@ -1687,7 +1698,8 @@ def _inversion_isomorphism(self):
16871698
From: Function field in T defined by T^3 + (x^4 + x^2 + 1)/x^6
16881699
To: Function field in y defined by y^3 + x^6 + x^4 + x^2
16891700
Defn: T |--> y
1690-
x |--> 1/x, Composite map:
1701+
x |--> 1/x,
1702+
Composite map:
16911703
From: Function field in y defined by y^3 + x^6 + x^4 + x^2
16921704
To: Function field in s defined by s^3 + x^16 + x^14 + x^12
16931705
Defn: Function Field morphism:

src/sage/rings/polynomial/polynomial_rational_flint.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ cdef class Polynomial_rational_flint(Polynomial):
336336
337337
INPUT:
338338
339-
- ``singular`` - Singular interpreter (default: default interpreter)
339+
- ``singular`` -- Singular interpreter (default: default interpreter)
340340
341341
EXAMPLES::
342342

src/sage/rings/puiseux_series_ring_element.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ Mind the base ring. However, the base ring can be changed::
4949
sage: I*q # needs sage.rings.number_field
5050
Traceback (most recent call last):
5151
...
52-
TypeError: unsupported operand parent(s) for *: 'Number Field in I with defining polynomial x^2 + 1 with I = 1*I' and 'Puiseux Series Ring in x over Rational Field'
52+
TypeError: unsupported operand parent(s) for *:
53+
'Number Field in I with defining polynomial x^2 + 1 with I = 1*I' and
54+
'Puiseux Series Ring in x over Rational Field'
5355
sage: qz = q.change_ring(ZZ); qz
5456
x^(1/3) + x^(1/2)
5557
sage: qz.parent()

src/sage/rings/qqbar.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@
269269
Bailey, Yozo, Li and Thompson discusses this result. Evidently it is
270270
difficult to find, but we can easily verify it. ::
271271
272-
sage: alpha = QQbar.polynomial_root(x^10 + x^9 - x^7 - x^6 - x^5 - x^4 - x^3 + x + 1, RIF(1, 1.2))
272+
sage: alpha = QQbar.polynomial_root(x^10 + x^9 - x^7 - x^6
273+
....: - x^5 - x^4 - x^3 + x + 1, RIF(1, 1.2))
273274
sage: lhs = alpha^630 - 1
274275
sage: rhs_num = (alpha^315 - 1) * (alpha^210 - 1) * (alpha^126 - 1)^2 * (alpha^90 - 1) * (alpha^3 - 1)^3 * (alpha^2 - 1)^5 * (alpha - 1)^3
275276
sage: rhs_den = (alpha^35 - 1) * (alpha^15 - 1)^2 * (alpha^14 - 1)^2 * (alpha^5 - 1)^6 * alpha^68
@@ -468,8 +469,10 @@
468469
0.?e-15
469470
470471
sage: ax = polygen(AA)
471-
sage: x2 = AA.polynomial_root(256*ax**8 - 128*ax**7 - 448*ax**6 + 192*ax**5 + 240*ax**4 - 80*ax**3 - 40*ax**2 + 8*ax + 1, RIF(0.9829, 0.983))
472-
sage: y2 = (1-x2**2).sqrt()
472+
sage: x2 = AA.polynomial_root(256*ax**8 - 128*ax**7 - 448*ax**6 + 192*ax**5
473+
....: + 240*ax**4 - 80*ax**3 - 40*ax**2 + 8*ax + 1,
474+
....: RIF(0.9829, 0.983))
475+
sage: y2 = (1 - x2**2).sqrt()
473476
sage: x - x2
474477
0.?e-18
475478
sage: y - y2
@@ -485,7 +488,8 @@
485488
sage: x = AA['x'].gen()
486489
sage: P = 1/(1+x^4)
487490
sage: P.partial_fraction_decomposition()
488-
(0, [(-0.3535533905932738?*x + 1/2)/(x^2 - 1.414213562373095?*x + 1), (0.3535533905932738?*x + 1/2)/(x^2 + 1.414213562373095?*x + 1)])
491+
(0, [(-0.3535533905932738?*x + 1/2)/(x^2 - 1.414213562373095?*x + 1),
492+
(0.3535533905932738?*x + 1/2)/(x^2 + 1.414213562373095?*x + 1)])
489493
490494
Check that :issue:`22202` is fixed::
491495
@@ -2638,7 +2642,8 @@ def number_field_elements_from_algebraics(numbers, minimal=False,
26382642
Things work fine with rational numbers, too::
26392643
26402644
sage: number_field_elements_from_algebraics((QQbar(1/2), AA(17)))
2641-
(Rational Field, [1/2, 17], Ring morphism:
2645+
(Rational Field, [1/2, 17],
2646+
Ring morphism:
26422647
From: Rational Field
26432648
To: Algebraic Real Field
26442649
Defn: 1 |--> 1)
@@ -2690,8 +2695,8 @@ def number_field_elements_from_algebraics(numbers, minimal=False,
26902695
It is also possible to have an embedded Number Field::
26912696
26922697
sage: x = polygen(ZZ)
2693-
sage: my_num = AA.polynomial_root(x^3-2, RIF(0,3))
2694-
sage: res = number_field_elements_from_algebraics(my_num,embedded=True)
2698+
sage: my_num = AA.polynomial_root(x^3 - 2, RIF(0,3))
2699+
sage: res = number_field_elements_from_algebraics(my_num, embedded=True)
26952700
sage: res[0].gen_embedding()
26962701
1.259921049894873?
26972702
sage: res[2]
@@ -2783,12 +2788,14 @@ def number_field_elements_from_algebraics(numbers, minimal=False,
27832788
Tests trivial cases::
27842789
27852790
sage: number_field_elements_from_algebraics([], embedded=True)
2786-
(Rational Field, [], Ring morphism:
2791+
(Rational Field, [],
2792+
Ring morphism:
27872793
From: Rational Field
27882794
To: Algebraic Real Field
27892795
Defn: 1 |--> 1)
27902796
sage: number_field_elements_from_algebraics([1], embedded=True)
2791-
(Rational Field, [1], Ring morphism:
2797+
(Rational Field, [1],
2798+
Ring morphism:
27922799
From: Rational Field
27932800
To: Algebraic Real Field
27942801
Defn: 1 |--> 1)
@@ -2798,7 +2805,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False,
27982805
sage: # needs sage.libs.gap sage.symbolic
27992806
sage: UCF = UniversalCyclotomicField()
28002807
sage: E = UCF.gen(5)
2801-
sage: L.<b> = NumberField(x^2-189*x+16, embedding=200)
2808+
sage: L.<b> = NumberField(x^2 - 189*x + 16, embedding=200)
28022809
sage: x = polygen(ZZ)
28032810
sage: my_nums = [-52*E - 136*E^2 - 136*E^3 - 52*E^4,
28042811
....: L.gen()._algebraic_(AA),
@@ -4382,7 +4389,8 @@ def as_number_field_element(self, minimal=False, embedded=False, prec=53):
43824389
sage: AA(elt)
43834390
Traceback (most recent call last):
43844391
...
4385-
ValueError: need a real or complex embedding to convert a non rational element of a number field into an algebraic number
4392+
ValueError: need a real or complex embedding to convert a non rational
4393+
element of a number field into an algebraic number
43864394
sage: hom(elt) == rt
43874395
True
43884396
@@ -4391,7 +4399,8 @@ def as_number_field_element(self, minimal=False, embedded=False, prec=53):
43914399
sage: (nf, elt, hom) = rt.as_number_field_element(embedded=True)
43924400
sage: nf.coerce_embedding()
43934401
Generic morphism:
4394-
From: Number Field in a with defining polynomial y^3 - 2*y^2 - 31*y - 50 with a = 7.237653139801104?
4402+
From: Number Field in a with defining polynomial y^3 - 2*y^2 - 31*y - 50
4403+
with a = 7.237653139801104?
43954404
To: Algebraic Real Field
43964405
Defn: a -> 7.237653139801104?
43974406
sage: elt
@@ -4518,9 +4527,11 @@ def _exact_field(self):
45184527
sage: QQbar(2)._exact_field()
45194528
Trivial generator
45204529
sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
4521-
Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
4530+
Number Field in a with defining polynomial y^4 - 20*y^2 + 81
4531+
with a in -3.789313782671036?
45224532
sage: (QQbar(7)^(3/5))._exact_field()
4523-
Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
4533+
Number Field in a with defining polynomial
4534+
y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
45244535
"""
45254536
sd = self._descr
45264537
if isinstance(sd, (ANRational, ANExtensionElement)):

0 commit comments

Comments
 (0)