Skip to content

Commit ae81a48

Browse files
author
Matthias Koeppe
committed
sage.rings.polynomial: More block tags, doctest cosmetics
1 parent f4a10a0 commit ae81a48

9 files changed

+545
-476
lines changed

src/sage/rings/polynomial/multi_polynomial_element.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def _macaulay2_(self, macaulay2=None):
550550
EXAMPLES::
551551
552552
sage: R = GF(13)['a,b']['c,d']
553-
sage: macaulay2(R('a^2 + c')) # optional - macaulay2, needs sage.rings.finite_rings
553+
sage: macaulay2(R('a^2 + c')) # optional - macaulay2
554554
2
555555
c + a
556556
@@ -559,7 +559,7 @@ def _macaulay2_(self, macaulay2=None):
559559
Elements of the base ring are coerced to the polynomial ring
560560
correctly::
561561
562-
sage: macaulay2(R('a^2')).ring()._operator('===', R) # optional - macaulay2, needs sage.rings.finite_rings
562+
sage: macaulay2(R('a^2')).ring()._operator('===', R) # optional - macaulay2
563563
true
564564
"""
565565
if macaulay2 is None:

src/sage/rings/polynomial/multi_polynomial_ideal.py

+41-42
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ def _magma_init_(self, magma):
347347
348348
EXAMPLES::
349349
350-
sage: R.<a,b,c,d,e,f,g,h,i,j> = PolynomialRing(GF(127),10)
351-
sage: I = sage.rings.ideal.Cyclic(R,4) # indirect doctest # needs sage.rings.finite_rings
352-
sage: magma(I) # optional - magma # needs sage.rings.finite_rings
350+
sage: # optional - magma
351+
sage: R.<a,b,c,d,e,f,g,h,i,j> = PolynomialRing(GF(127), 10)
352+
sage: I = sage.rings.ideal.Cyclic(R,4) # indirect doctest
353+
sage: magma(I)
353354
Ideal of Polynomial ring of rank 10 over GF(127)
354355
Order: Graded Reverse Lexicographical
355356
Variables: a, b, c, d, e, f, g, h, i, j
@@ -384,20 +385,20 @@ def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default)
384385
385386
EXAMPLES::
386387
387-
sage: # needs sage.rings.finite_rings
388+
sage: # optional - magma
388389
sage: R.<a,b,c,d,e,f,g,h,i,j> = PolynomialRing(GF(127), 10)
389390
sage: I = sage.rings.ideal.Cyclic(R, 6)
390-
sage: gb = I.groebner_basis('magma:GroebnerBasis') # optional - magma
391-
sage: len(gb) # optional - magma
391+
sage: gb = I.groebner_basis('magma:GroebnerBasis')
392+
sage: len(gb)
392393
45
393394
394395
We may also pass a degree bound to Magma::
395396
396-
sage: # needs sage.rings.finite_rings
397+
sage: # optional - magma
397398
sage: R.<a,b,c,d,e,f,g,h,i,j> = PolynomialRing(GF(127), 10)
398399
sage: I = sage.rings.ideal.Cyclic(R, 6)
399-
sage: gb = I.groebner_basis('magma:GroebnerBasis', deg_bound=4) # optional - magma
400-
sage: len(gb) # optional - magma
400+
sage: gb = I.groebner_basis('magma:GroebnerBasis', deg_bound=4)
401+
sage: len(gb)
401402
5
402403
"""
403404
R = self.ring()
@@ -1354,14 +1355,14 @@ def _groebner_basis_ginv(self, algorithm="TQ", criteria='CritPartially', divisio
13541355
13551356
Currently, only `\GF{p}` and `\QQ` are supported as base fields::
13561357
1357-
sage: P.<x,y,z> = PolynomialRing(QQ,order='degrevlex')
1358+
sage: # optional - ginv
1359+
sage: P.<x,y,z> = PolynomialRing(QQ, order='degrevlex')
13581360
sage: I = sage.rings.ideal.Katsura(P)
1359-
sage: I.groebner_basis(algorithm='ginv') # optional - ginv
1361+
sage: I.groebner_basis(algorithm='ginv')
13601362
[z^3 - 79/210*z^2 + 1/30*y + 1/70*z, y^2 - 3/5*z^2 - 1/5*y + 1/5*z, y*z + 6/5*z^2 - 1/10*y - 2/5*z, x + 2*y + 2*z - 1]
1361-
13621363
sage: P.<x,y,z> = PolynomialRing(GF(127), order='degrevlex')
1363-
sage: I = sage.rings.ideal.Katsura(P) # needs sage.rings.finite_rings
1364-
sage: I.groebner_basis(algorithm='ginv') # optional - ginv # needs sage.rings.finite_rings
1364+
sage: I = sage.rings.ideal.Katsura(P)
1365+
sage: I.groebner_basis(algorithm='ginv')
13651366
...
13661367
[z^3 + 22*z^2 - 55*y + 49*z, y^2 - 26*z^2 - 51*y + 51*z, y*z + 52*z^2 + 38*y + 25*z, x + 2*y + 2*z - 1]
13671368
@@ -1979,7 +1980,7 @@ def interreduced_basis(self):
19791980
The interreduced basis of 0 is 0::
19801981
19811982
sage: P.<x,y,z> = GF(2)[]
1982-
sage: Ideal(P(0)).interreduced_basis() # needs sage.rings.finite_rings
1983+
sage: Ideal(P(0)).interreduced_basis()
19831984
[0]
19841985
19851986
ALGORITHM:
@@ -2526,8 +2527,6 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True
25262527
y^48 + y^41 - y^40 + y^37 - y^36 - y^33 + y^32 - y^29 + y^28
25272528
- y^25 + y^24 + y^2 + y + 1)
25282529
of Multivariate Polynomial Ring in x, y over Finite Field in w of size 3^3
2529-
2530-
sage: # needs sage.rings.finite_rings
25312530
sage: V = I.variety();
25322531
sage: sorted(V, key=str)
25332532
[{y: w^2 + 2*w, x: 2*w + 2}, {y: w^2 + 2, x: 2*w}, {y: w^2 + w, x: 2*w + 1}]
@@ -2610,9 +2609,10 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True
26102609
If the ground field's characteristic is too large for
26112610
Singular, we resort to a toy implementation::
26122611
2613-
sage: R.<x,y> = PolynomialRing(GF(2147483659^3), order='lex') # needs sage.rings.finite_rings
2614-
sage: I = ideal([x^3 - 2*y^2, 3*x + y^4]) # needs sage.rings.finite_rings
2615-
sage: I.variety() # needs sage.rings.finite_rings
2612+
sage: # needs sage.rings.finite_rings
2613+
sage: R.<x,y> = PolynomialRing(GF(2147483659^3), order='lex')
2614+
sage: I = ideal([x^3 - 2*y^2, 3*x + y^4])
2615+
sage: I.variety()
26162616
verbose 0 (...: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
26172617
verbose 0 (...: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation.
26182618
verbose 0 (...: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
@@ -2623,22 +2623,23 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True
26232623
But the mapping will also accept generators of the original ring,
26242624
or even generator names as strings, when provided as keys::
26252625
2626+
sage: # needs sage.rings.number_field
26262627
sage: K.<x,y> = QQ[]
26272628
sage: I = ideal([x^2 + 2*y - 5, x + y + 3])
2628-
sage: v = I.variety(AA)[0]; v[x], v[y] # needs sage.rings.number_field
2629+
sage: v = I.variety(AA)[0]; v[x], v[y]
26292630
(4.464101615137755?, -7.464101615137755?)
2630-
sage: list(v)[0].parent() # needs sage.rings.number_field
2631+
sage: list(v)[0].parent()
26312632
Multivariate Polynomial Ring in x, y over Algebraic Real Field
2632-
sage: v[x] # needs sage.rings.number_field
2633+
sage: v[x]
26332634
4.464101615137755?
2634-
sage: v["y"] # needs sage.rings.number_field
2635+
sage: v["y"]
26352636
-7.464101615137755?
26362637
26372638
``msolve`` also works over finite fields::
26382639
26392640
sage: R.<x, y> = PolynomialRing(GF(536870909), 2, order='lex') # needs sage.rings.finite_rings
26402641
sage: I = Ideal([x^2 - 1, y^2 - 1]) # needs sage.rings.finite_rings
2641-
sage: sorted(I.variety(algorithm='msolve', # optional - msolve # needs sage.rings.finite_rings
2642+
sage: sorted(I.variety(algorithm='msolve', # optional - msolve, needs sage.rings.finite_rings
26422643
....: proof=False),
26432644
....: key=str)
26442645
[{x: 1, y: 1},
@@ -2651,7 +2652,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True
26512652
26522653
sage: R.<x, y> = PolynomialRing(GF(3), 2, order='lex')
26532654
sage: I = Ideal([x^2 - 1, y^2 - 1])
2654-
sage: I.variety(algorithm='msolve', proof=False) # optional - msolve, needs sage.rings.finite_rings
2655+
sage: I.variety(algorithm='msolve', proof=False) # optional - msolve
26552656
Traceback (most recent call last):
26562657
...
26572658
NotImplementedError: characteristic 3 too small
@@ -2710,10 +2711,10 @@ def _variety_triangular_decomposition(self, ring):
27102711
x11^2 + x11, x12^2 + x12, x13^2 + x13, x14^2 + x14, x15^2 + x15, \
27112712
x16^2 + x16, x17^2 + x17, x18^2 + x18, x19^2 + x19, x20^2 + x20, \
27122713
x21^2 + x21, x22^2 + x22, x23^2 + x23, x24^2 + x24, x25^2 + x25, \
2713-
x26^2 + x26, x27^2 + x27, x28^2 + x28, x29^2 + x29, x30^2 + x30]) # optional - sage.rings.finite_rings
2714-
sage: I.basis_is_groebner() # needs sage.rings.finite_rings
2714+
x26^2 + x26, x27^2 + x27, x28^2 + x28, x29^2 + x29, x30^2 + x30])
2715+
sage: I.basis_is_groebner()
27152716
True
2716-
sage: sorted("".join(str(V[g]) for g in R.gens()) for V in I.variety()) # long time (6s on sage.math, 2011), needs sage.rings.finite_rings
2717+
sage: sorted("".join(str(V[g]) for g in R.gens()) for V in I.variety()) # long time (6s on sage.math, 2011)
27172718
['101000100000000110001000100110',
27182719
'101000100000000110001000101110',
27192720
'101000100100000101001000100110',
@@ -2748,10 +2749,10 @@ def _variety_triangular_decomposition(self, ring):
27482749
27492750
Check that the issue at :trac:`7425` is fixed::
27502751
2751-
sage: S.<t>=PolynomialRing(QQ)
2752-
sage: F.<q>=QQ.extension(t^4+1)
2753-
sage: R.<x,y>=PolynomialRing(F)
2754-
sage: I=R.ideal(x,y^4+1)
2752+
sage: S.<t> = PolynomialRing(QQ)
2753+
sage: F.<q> = QQ.extension(t^4 + 1)
2754+
sage: R.<x,y> = PolynomialRing(F)
2755+
sage: I = R.ideal(x, y^4 + 1)
27552756
sage: I.variety()
27562757
[...{y: -q^3, x: 0}...]
27572758
@@ -2765,7 +2766,7 @@ def _variety_triangular_decomposition(self, ring):
27652766
Check that the issue at :trac:`16485` is fixed::
27662767
27672768
sage: R.<a,b,c> = PolynomialRing(QQ, order='lex')
2768-
sage: I = R.ideal(c^2-2, b-c, a)
2769+
sage: I = R.ideal(c^2 - 2, b - c, a)
27692770
sage: I.variety(QQbar) # needs sage.rings.number_field
27702771
[...a: 0...]
27712772
@@ -4649,10 +4650,10 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
46494650
if not algorithm:
46504651
try:
46514652
gb = self._groebner_basis_libsingular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
4652-
except (TypeError, NameError, ImportError): # conversion to Singular not supported
4653+
except (TypeError, NameError, ImportError): # conversion to Singular not supported
46534654
try:
46544655
gb = self._groebner_basis_singular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
4655-
except (TypeError, NameError, NotImplementedError, ImportError): # conversion to Singular not supported
4656+
except (TypeError, NameError, NotImplementedError, ImportError): # conversion to Singular not supported
46564657
R = self.ring()
46574658
B = R.base_ring()
46584659
if R.ngens() == 0:
@@ -5420,8 +5421,7 @@ def weil_restriction(self):
54205421
sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal
54215422
sage: J.variety()
54225423
[{y1: 1, y0: 0, x1: 1, x0: 1}]
5423-
5424-
sage: J.weil_restriction() # returns J # needs sage.rings.finite_rings
5424+
sage: J.weil_restriction() # returns J
54255425
Ideal (x0*y0 + x1*y1 + 1, x1*y0 + x0*y1 + x1*y1, x1 + 1, x0 + x1,
54265426
x0^2 + x0, x1^2 + x1, y0^2 + y0, y1^2 + y1) of Multivariate
54275427
Polynomial Ring in x0, x1, y0, y1 over Finite Field of size 2
@@ -5434,8 +5434,7 @@ def weil_restriction(self):
54345434
0
54355435
sage: I.variety()
54365436
[{z: 0, y: 0, x: 1}]
5437-
5438-
sage: J = I.weil_restriction(); J # needs sage.rings.finite_rings
5437+
sage: J = I.weil_restriction(); J
54395438
Ideal (x0 - y0 - z0 - 1,
54405439
x1 - y1 - z1, x2 - y2 - z2, x3 - y3 - z3, x4 - y4 - z4,
54415440
x0^2 + x2*x3 + x1*x4 - y0^2 - y2*y3 - y1*y4 - z0^2 - z2*z3 - z1*z4 - x0,
@@ -5460,9 +5459,9 @@ def weil_restriction(self):
54605459
- y4*z0 - y3*z1 - y2*z2 - y1*z3 - y0*z4 - y4*z4 - y4)
54615460
of Multivariate Polynomial Ring in x0, x1, x2, x3, x4, y0, y1, y2, y3, y4,
54625461
z0, z1, z2, z3, z4 over Finite Field of size 3
5463-
sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal # needs sage.rings.finite_rings
5462+
sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal
54645463
sage: from sage.doctest.fixtures import reproducible_repr
5465-
sage: print(reproducible_repr(J.variety())) # needs sage.rings.finite_rings
5464+
sage: print(reproducible_repr(J.variety()))
54665465
[{x0: 1, x1: 0, x2: 0, x3: 0, x4: 0,
54675466
y0: 0, y1: 0, y2: 0, y3: 0, y4: 0,
54685467
z0: 0, z1: 0, z2: 0, z3: 0, z4: 0}]

src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5080,7 +5080,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
50805080
50815081
sage: # optional - macaulay2
50825082
sage: R.<x,y> = PolynomialRing(GF(7), 2)
5083-
sage: f = (x^3 + 2*y^2*x)^7; f
5083+
sage: f = (x^3 + 2*y^2*x)^7; f # indirect doctest
50845084
x^21 + 2*x^7*y^14
50855085
sage: h = macaulay2(f); h
50865086
21 7 14

0 commit comments

Comments
 (0)