Skip to content

Commit

Permalink
More # optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Feb 5, 2023
1 parent d534fb6 commit 716c6d7
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 120 deletions.
76 changes: 39 additions & 37 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,9 @@ def is_prime(n):
However, number fields redefine ``.is_prime()`` in an incompatible fashion
(cf. :trac:`32340`) and we should not warn::
sage: K.<i> = NumberField(x^2+1)
sage: is_prime(1+i)
sage: x = polygen(ZZ, 'x')
sage: K.<i> = NumberField(x^2 + 1) # optional - sage.rings.number_field
sage: is_prime(1 + i) # optional - sage.rings.number_field
True
"""
try:
Expand Down Expand Up @@ -2510,10 +2511,10 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
EXAMPLES::
sage: f(n)=n^2
sage: is_prime(f(3))
sage: f(n) = n^2 # optional - sage.symbolic
sage: is_prime(f(3)) # optional - sage.symbolic
False
sage: factor(f(3))
sage: factor(f(3)) # optional - sage.symbolic
9
INPUT:
Expand Down Expand Up @@ -3337,33 +3338,34 @@ def crt(a, b, m=None, n=None):
Note that this also works for polynomial rings::
sage: K.<a> = NumberField(x^3 - 7)
sage: R.<y> = K[]
sage: f = y^2 + 3
sage: g = y^3 - 5
sage: CRT(1,3,f,g)
sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 - 7) # optional - sage.rings.number_field
sage: R.<y> = K[] # optional - sage.rings.number_field
sage: f = y^2 + 3 # optional - sage.rings.number_field
sage: g = y^3 - 5 # optional - sage.rings.number_field
sage: CRT(1, 3, f, g) # optional - sage.rings.number_field
-3/26*y^4 + 5/26*y^3 + 15/26*y + 53/26
sage: CRT(1,a,f,g)
sage: CRT(1, a, f, g) # optional - sage.rings.number_field
(-3/52*a + 3/52)*y^4 + (5/52*a - 5/52)*y^3 + (15/52*a - 15/52)*y + 27/52*a + 25/52
You can also do this for any number of moduli::
sage: K.<a> = NumberField(x^3 - 7)
sage: R.<x> = K[]
sage: CRT([], [])
sage: K.<a> = NumberField(x^3 - 7) # optional - sage.rings.number_field
sage: R.<x> = K[] # optional - sage.rings.number_field
sage: CRT([], []) # optional - sage.rings.number_field
0
sage: CRT([a], [x])
sage: CRT([a], [x]) # optional - sage.rings.number_field
a
sage: f = x^2 + 3
sage: g = x^3 - 5
sage: h = x^5 + x^2 - 9
sage: k = CRT([1, a, 3], [f, g, h]); k
sage: f = x^2 + 3 # optional - sage.rings.number_field
sage: g = x^3 - 5 # optional - sage.rings.number_field
sage: h = x^5 + x^2 - 9 # optional - sage.rings.number_field
sage: k = CRT([1, a, 3], [f, g, h]); k # optional - sage.rings.number_field
(127/26988*a - 5807/386828)*x^9 + (45/8996*a - 33677/1160484)*x^8 + (2/173*a - 6/173)*x^7 + (133/6747*a - 5373/96707)*x^6 + (-6/2249*a + 18584/290121)*x^5 + (-277/8996*a + 38847/386828)*x^4 + (-135/4498*a + 42673/193414)*x^3 + (-1005/8996*a + 470245/1160484)*x^2 + (-1215/8996*a + 141165/386828)*x + 621/8996*a + 836445/386828
sage: k.mod(f)
sage: k.mod(f) # optional - sage.rings.number_field
1
sage: k.mod(g)
sage: k.mod(g) # optional - sage.rings.number_field
a
sage: k.mod(h)
sage: k.mod(h) # optional - sage.rings.number_field
3
If the moduli are not coprime, a solution may not exist::
Expand Down Expand Up @@ -3646,11 +3648,11 @@ def binomial(x, m, **kwds):
0
sage: binomial(RealField()('2.5'), 2)
1.87500000000000
sage: n=var('n'); binomial(n,2)
sage: n = var('n'); binomial(n, 2) # optional - sage.symbolic
1/2*(n - 1)*n
sage: n=var('n'); binomial(n,n)
sage: n = var('n'); binomial(n, n) # optional - sage.symbolic
1
sage: n=var('n'); binomial(n,n-1)
sage: n = var('n'); binomial(n, n-1) # optional - sage.symbolic
n
sage: binomial(2^100, 2^100)
1
Expand Down Expand Up @@ -3750,8 +3752,8 @@ def binomial(x, m, **kwds):
...
TypeError: either m or x-m must be an integer
sage: k, i = var('k,i')
sage: binomial(k,i)
sage: k, i = var('k,i') # optional - sage.symbolic
sage: binomial(k,i) # optional - sage.symbolic
Traceback (most recent call last):
...
TypeError: either m or x-m must be an integer
Expand Down Expand Up @@ -3788,8 +3790,8 @@ def binomial(x, m, **kwds):
:func:`~sage.functions.other.binomial` from the module
:mod:`sage.functions.other`::
sage: from sage.functions.other import binomial
sage: binomial(k, i)
sage: from sage.functions.other import binomial # optional - sage.symbolic
sage: binomial(k, i) # optional - sage.symbolic
binomial(k, i)
binomial support numpy and gmpy2 parameters::
Expand Down Expand Up @@ -5015,17 +5017,17 @@ def falling_factorial(x, a):
sage: falling_factorial(10, 3)
720
sage: falling_factorial(10, RR('3.0'))
sage: falling_factorial(10, RR('3.0')) # optional - sage.symbolic
720.000000000000
sage: falling_factorial(10, RR('3.3'))
sage: falling_factorial(10, RR('3.3')) # optional - sage.symbolic
1310.11633396601
sage: falling_factorial(10, 10)
3628800
sage: factorial(10)
3628800
sage: a = falling_factorial(1+I, I); a
sage: a = falling_factorial(1+I, I); a # optional - sage.symbolic
gamma(I + 2)
sage: CC(a)
sage: CC(a) # optional - sage.symbolic
0.652965496420167 + 0.343065839816545*I
sage: falling_factorial(1+I, 4)
4*I + 2
Expand Down Expand Up @@ -5053,8 +5055,8 @@ def falling_factorial(x, a):
Check that :trac:`16770` is fixed::
sage: d = var('d')
sage: parent(falling_factorial(d, 0))
sage: d = var('d') # optional - sage.symbolic
sage: parent(falling_factorial(d, 0)) # optional - sage.symbolic
Symbolic Ring
Check that :trac:`20075` is fixed::
Expand Down Expand Up @@ -5188,7 +5190,7 @@ def integer_ceil(x):
sage: integer_ceil(5.4)
6
sage: integer_ceil(x)
sage: integer_ceil(x) # optional - sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of ceil of x not implemented
Expand Down Expand Up @@ -5234,7 +5236,7 @@ def integer_floor(x):
sage: integer_floor(RDF(-5/2))
-3
sage: integer_floor(x)
sage: integer_floor(x) # optional - sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of floor of x not implemented
Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ def inverse_of_unit(self):
EXAMPLES::
sage: NumberField(x^7+2,'a')(2).inverse_of_unit()
sage: x = polygen(ZZ, 'x')
sage: NumberField(x^7+2, 'a')(2).inverse_of_unit() # optional - sage.rings.number_field
1/2
Trying to invert the zero element typically raises a
Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/number_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def _test_absolute_disc(self, **options):
EXAMPLES::
sage: S = NumberField(x**3-x-1, 'a')
sage: x = polygen(ZZ, 'x')
sage: S = NumberField(x**3 - x - 1, 'a')
sage: S._test_absolute_disc()
"""
from sage.rings.integer import Integer
Expand Down
12 changes: 6 additions & 6 deletions src/sage/combinat/designs/block_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,19 @@ def q3_minus_one_matrix(K):
sage: from sage.combinat.designs.block_design import q3_minus_one_matrix
sage: m = q3_minus_one_matrix(GF(3))
sage: m.multiplicative_order() == 3**3 - 1
sage: m.multiplicative_order() == 3**3 - 1 # optional - sage.symbolic
True
sage: m = q3_minus_one_matrix(GF(4,'a'))
sage: m.multiplicative_order() == 4**3 - 1
sage: m = q3_minus_one_matrix(GF(4, 'a'))
sage: m.multiplicative_order() == 4**3 - 1 # optional - sage.symbolic
True
sage: m = q3_minus_one_matrix(GF(5))
sage: m.multiplicative_order() == 5**3 - 1
sage: m.multiplicative_order() == 5**3 - 1 # optional - sage.symbolic
True
sage: m = q3_minus_one_matrix(GF(9,'a'))
sage: m.multiplicative_order() == 9**3 - 1
sage: m = q3_minus_one_matrix(GF(9, 'a'))
sage: m.multiplicative_order() == 9**3 - 1 # optional - sage.symbolic
True
"""
q = K.cardinality()
Expand Down
14 changes: 7 additions & 7 deletions src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,9 +2053,9 @@ def order(self):
EXAMPLES::
sage: q = var('q')
sage: PA = PartitionAlgebra(2, q)
sage: PA.order()
sage: q = var('q') # optional - sage.symbolic
sage: PA = PartitionAlgebra(2, q) # optional - sage.symbolic
sage: PA.order() # optional - sage.symbolic
2
"""
return self._k
Expand Down Expand Up @@ -2412,12 +2412,12 @@ class PartitionAlgebra(DiagramBasis, UnitDiagramMixin):
::
sage: q = var('q')
sage: PA = PartitionAlgebra(2, q); PA
sage: q = var('q') # optional - sage.symbolic
sage: PA = PartitionAlgebra(2, q); PA # optional - sage.symbolic
Partition Algebra of rank 2 with parameter q over Symbolic Ring
sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]])
sage: PA([[1,2],[-2,-1]])^2 == q*PA([[1,2],[-2,-1]]) # optional - sage.symbolic
True
sage: (PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 == (4*q-4)*PA([[1, 2], [-2, -1]]) + PA([[2, -2], [1, -1]])
sage: (PA([[2, -2], [1, -1]]) - 2*PA([[-2, -1], [1, 2]]))^2 == (4*q-4)*PA([[1, 2], [-2, -1]]) + PA([[2, -2], [1, -1]]) # optional - sage.symbolic
True
The identity element of the partition algebra is the set
Expand Down
Loading

0 comments on commit 716c6d7

Please sign in to comment.