Skip to content

Commit

Permalink
Use more block tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Aug 12, 2023
1 parent 887959e commit 8cb3795
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 206 deletions.
151 changes: 81 additions & 70 deletions src/sage/misc/cachefunc.pyx

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/sage/misc/converting_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
This is used e.g. in the result of a variety, to allow access to the
result no matter how a generator is identified::
sage: # needs sage.rings.number_field
sage: K.<x,y> = QQ[]
sage: I = ideal([x^2 + 2*y - 5, x + y + 3])
sage: V = sorted(I.variety(AA), key=str) # needs sage.rings.number_field
sage: v = V[0] # needs sage.rings.number_field
sage: v['x'], v['y'] # needs sage.rings.number_field
sage: V = sorted(I.variety(AA), key=str)
sage: v = V[0]
sage: v['x'], v['y']
(-2.464101615137755?, -0.535898384862246?)
sage: list(v)[0].parent() # needs sage.rings.number_field
sage: list(v)[0].parent()
Multivariate Polynomial Ring in x, y over Algebraic Real Field
"""
# ****************************************************************************
Expand Down
9 changes: 5 additions & 4 deletions src/sage/misc/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,15 @@ class infix_operator():
An infix element-wise addition operator::
sage: # needs sage.modules
sage: @infix_operator('add')
....: def eadd(a, b):
....: return a.parent([i + j for i, j in zip(a, b)])
sage: u = vector([1, 2, 3]) # needs sage.modules
sage: v = vector([5, 4, 3]) # needs sage.modules
sage: u +eadd+ v # needs sage.modules
sage: u = vector([1, 2, 3])
sage: v = vector([5, 4, 3])
sage: u +eadd+ v
(6, 6, 6)
sage: 2*u +eadd+ v # needs sage.modules
sage: 2*u +eadd+ v
(7, 8, 9)
A hack to simulate a postfix operator::
Expand Down
9 changes: 5 additions & 4 deletions src/sage/misc/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ def find_objects_from_name(name, module_name=None):
sage: dt.find_objects_from_name('FareySymbol') # needs sage.modular
[<class 'sage.modular.arithgroup.farey_symbol.Farey'>]
sage: import sympy # needs sympy
sage: dt.find_objects_from_name('RR') # needs sympy
sage: # needs sympy
sage: import sympy
sage: dt.find_objects_from_name('RR')
[Real Field with 53 bits of precision, RR]
sage: dt.find_objects_from_name('RR', 'sage') # needs sympy
sage: dt.find_objects_from_name('RR', 'sage')
[Real Field with 53 bits of precision]
sage: dt.find_objects_from_name('RR', 'sympy') # needs sympy
sage: dt.find_objects_from_name('RR', 'sympy')
[RR]
Examples that do not belong to the global namespace but in a loaded module::
Expand Down
12 changes: 6 additions & 6 deletions src/sage/misc/element_with_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ class ElementWithLabel():
sage: print(P.plot(element_labels=labs)) # needs sage.plot
Graphics object consisting of 6 graphics primitives
sage: # needs sage.combinat sage.modules
sage: # needs sage.combinat sage.graphs sage.modules
sage: from sage.misc.element_with_label import ElementWithLabel
sage: W = WeylGroup("A1")
sage: P = W.bruhat_poset(facade=True) # needs sage.graphs
sage: D = W.domain() # needs sage.graphs
sage: v = D.rho() - D.fundamental_weight(1) # needs sage.graphs
sage: nP = P.relabel(lambda w: ElementWithLabel(w, w.action(v))) # needs sage.graphs
sage: list(nP) # needs sage.graphs
sage: P = W.bruhat_poset(facade=True)
sage: D = W.domain()
sage: v = D.rho() - D.fundamental_weight(1)
sage: nP = P.relabel(lambda w: ElementWithLabel(w, w.action(v)))
sage: list(nP)
[(0, 0), (0, 0)]
"""
def __init__(self, element, label):
Expand Down
3 changes: 1 addition & 2 deletions src/sage/misc/function_mangling.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ cdef class ArgumentFixer:
EXAMPLES::
sage: from sage.misc.function_mangling import ArgumentFixer
sage: g = ArgumentFixer(number_of_partitions) # needs sage.combinat
sage: g # needs sage.combinat
sage: g = ArgumentFixer(number_of_partitions); g # needs sage.combinat
Argument Fixer of <function number_of_partitions at 0x...>
"""
return "Argument Fixer of %s"%self.f
Expand Down
61 changes: 33 additions & 28 deletions src/sage/misc/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ def characteristic_polynomial(x, var='x'):
EXAMPLES::
sage: # needs sage.modules
sage: # needs sage.libs.pari sage.modules
sage: M = MatrixSpace(QQ, 3, 3)
sage: A = M([1,2,3,4,5,6,7,8,9])
sage: charpoly(A) # needs sage.libs.pari
sage: charpoly(A)
x^3 - 15*x^2 - 18*x
sage: charpoly(A, 't') # needs sage.libs.pari
sage: charpoly(A, 't')
t^3 - 15*t^2 - 18*t
sage: k.<alpha> = GF(7^10); k # needs sage.rings.finite_rings
Expand Down Expand Up @@ -728,11 +728,11 @@ def integral(x, *args, **kwds):
sage: sage.calculus.calculus.maxima('domain: real')
real
sage: f = exp(-x) * sinh(sqrt(x))
sage: t = integrate(f, x, 0, Infinity); t # long time
sage: t = integrate(f, x, 0, Infinity); t # long time
1/4*sqrt(pi)*(erf(1) - 1)*e^(1/4)
- 1/4*(sqrt(pi)*(erf(1) - 1) - sqrt(pi) + 2*e^(-1) - 2)*e^(1/4)
+ 1/4*sqrt(pi)*e^(1/4) - 1/2*e^(1/4) + 1/2*e^(-3/4)
sage: t.canonicalize_radical() # long time
sage: t.canonicalize_radical() # long time
1/2*sqrt(pi)*e^(1/4)
sage: sage.calculus.calculus.maxima('domain: complex')
complex
Expand Down Expand Up @@ -770,10 +770,11 @@ def integral(x, *args, **kwds):
sage: integrate(sin(x)*tan(x)/(1-cos(x)), x, a, b, algorithm='sympy')
-integrate(sin(x)*tan(x)/(cos(x) - 1), x, a, b)
sage: import sympy # needs sympy
sage: x, y, z = sympy.symbols('x y z') # needs sympy
sage: f = sympy.Function('f') # needs sympy
sage: SR(sympy.Integral(f(x,y,z), x, y, z)) # needs sympy sage.symbolic
sage: # needs sympy
sage: import sympy
sage: x, y, z = sympy.symbols('x y z')
sage: f = sympy.Function('f')
sage: SR(sympy.Integral(f(x,y,z), x, y, z)) # needs sage.symbolic
integrate(integrate(integrate(f(x, y, z), x), y), z)
Ensure that the following integral containing a signum term from
Expand Down Expand Up @@ -1225,15 +1226,15 @@ def minimal_polynomial(x, var='x'):
EXAMPLES::
sage: # needs sage.modules
sage: # needs sage.libs.pari sage.modules
sage: a = matrix(ZZ, 2, [1..4])
sage: minpoly(a) # needs sage.libs.pari
sage: minpoly(a)
x^2 - 5*x - 2
sage: minpoly(a, 't') # needs sage.libs.pari
sage: minpoly(a, 't')
t^2 - 5*t - 2
sage: minimal_polynomial(a) # needs sage.libs.pari
sage: minimal_polynomial(a)
x^2 - 5*x - 2
sage: minimal_polynomial(a, 'theta') # needs sage.libs.pari
sage: minimal_polynomial(a, 'theta')
theta^2 - 5*theta - 2
"""
try:
Expand All @@ -1248,7 +1249,7 @@ def minimal_polynomial(x, var='x'):
def multiplicative_order(x):
r"""
Return the multiplicative order of ``x``, if ``x`` is a unit, or
raise ``ArithmeticError`` otherwise.
raise :class:`ArithmeticError` otherwise.
EXAMPLES::
Expand Down Expand Up @@ -1725,18 +1726,20 @@ def round(x, ndigits=0):
EXAMPLES::
sage: round(sqrt(2), 2) # needs sage.symbolic
sage: # needs sage.symbolic
sage: round(sqrt(2), 2)
1.41
sage: q = round(sqrt(2), 5); q # needs sage.symbolic
sage: q = round(sqrt(2), 5); q
1.41421
sage: type(q) # needs sage.symbolic
sage: type(q)
<class 'sage.rings.real_double...RealDoubleElement...'>
sage: q = round(sqrt(2)); q # needs sage.symbolic
sage: q = round(sqrt(2)); q
1
sage: type(q) # needs sage.symbolic
sage: type(q)
<class 'sage.rings.integer.Integer'>
sage: round(pi) # needs sage.symbolic
sage: round(pi)
3
sage: b = 5.4999999999999999
sage: round(b)
5
Expand Down Expand Up @@ -1954,17 +1957,19 @@ def sqrt(x, *args, **kwds):
EXAMPLES::
sage: sqrt(-1) # needs sage.symbolic
I
sage: sqrt(2) # needs sage.symbolic
sqrt(2)
sage: sqrt(2)^2 # needs sage.symbolic
2
sage: sqrt(4)
2
sage: sqrt(4, all=True)
[2, -2]
sage: sqrt(x^2) # needs sage.symbolic
sage: # needs sage.symbolic
sage: sqrt(-1)
I
sage: sqrt(2)
sqrt(2)
sage: sqrt(2)^2
2
sage: sqrt(x^2)
sqrt(x^2)
For a non-symbolic square root, there are a few options.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/gperftools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.symbolic
# sage.doctest: needs sage.symbolic
"""
C Function Profiler Using Google Perftools
Expand Down
11 changes: 6 additions & 5 deletions src/sage/misc/inline_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def eval(self, x, globals=None, locals=None):
EXAMPLES::
sage: # needs numpy
sage: code = '''
....: C FILE: FIB1.F
....: SUBROUTINE FIB(A,N)
Expand All @@ -111,11 +112,11 @@ def eval(self, x, globals=None, locals=None):
....: END
....: C END FILE FIB1.F
....: '''
sage: fortran(code, globals()) # needs numpy
sage: import numpy # needs numpy
sage: a = numpy.array(range(10), dtype=float) # needs numpy
sage: fib(a, 10) # needs numpy
sage: a # needs numpy
sage: fortran(code, globals())
sage: import numpy
sage: a = numpy.array(range(10), dtype=float)
sage: fib(a, 10)
sage: a
array([ 0., 1., 1., 2., 3., 5., 8., 13., 21., 34.])
TESTS::
Expand Down
31 changes: 17 additions & 14 deletions src/sage/misc/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ class Latex(LatexCall):
sage: latex(x^20 + 1) # needs sage.symbolic
x^{20} + 1
sage: latex(FiniteField(25,'a')) # needs sage.libs.pari
sage: latex(FiniteField(25,'a')) # needs sage.rings.finite_rings
\Bold{F}_{5^{2}}
sage: latex("hello")
\text{\texttt{hello}}
Expand Down Expand Up @@ -1216,18 +1216,19 @@ def matrix_delimiters(self, left=None, right=None):
EXAMPLES::
sage: a = matrix(1, 1, [17]) # needs sage.modules
sage: latex(a) # needs sage.modules
sage: # needs sage.modules
sage: a = matrix(1, 1, [17])
sage: latex(a)
\left(\begin{array}{r}
17
\end{array}\right)
sage: latex.matrix_delimiters("[", "]")
sage: latex(a) # needs sage.modules
sage: latex(a)
\left[\begin{array}{r}
17
\end{array}\right]
sage: latex.matrix_delimiters(left="\\{")
sage: latex(a) # needs sage.modules
sage: latex(a)
\left\{\begin{array}{r}
17
\end{array}\right]
Expand Down Expand Up @@ -1277,14 +1278,15 @@ def vector_delimiters(self, left=None, right=None):
EXAMPLES::
sage: a = vector(QQ, [1,2,3]) # needs sage.modules
sage: latex(a) # needs sage.modules
sage: # needs sage.modules
sage: a = vector(QQ, [1,2,3])
sage: latex(a)
\left(1,\,2,\,3\right)
sage: latex.vector_delimiters("[", "]")
sage: latex(a) # needs sage.modules
sage: latex(a)
\left[1,\,2,\,3\right]
sage: latex.vector_delimiters(right="\\}")
sage: latex(a) # needs sage.modules
sage: latex(a)
\left[1,\,2,\,3\right\}
sage: latex.vector_delimiters()
['[', '\\}']
Expand Down Expand Up @@ -1322,18 +1324,19 @@ def matrix_column_alignment(self, align=None):
EXAMPLES::
sage: a = matrix(1, 1, [42]) # needs sage.modules
sage: latex(a) # needs sage.modules
sage: # needs sage.modules
sage: a = matrix(1, 1, [42])
sage: latex(a)
\left(\begin{array}{r}
42
\end{array}\right)
sage: latex.matrix_column_alignment('c')
sage: latex(a) # needs sage.modules
sage: latex(a)
\left(\begin{array}{c}
42
\end{array}\right)
sage: latex.matrix_column_alignment('l')
sage: latex(a) # needs sage.modules
sage: latex(a)
\left(\begin{array}{l}
42
\end{array}\right)
Expand Down Expand Up @@ -1971,7 +1974,7 @@ def png(x, filename, density=150, debug=False,
sage: from sage.misc.latex import png
sage: import tempfile
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # optional - imagemagick latex, needs sage.plot
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # random # optional - imagemagick latex, needs sage.plot
....: png(ZZ[x], f.name)
"""
if not pdflatex:
Expand Down
9 changes: 5 additions & 4 deletions src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,12 @@ cdef class LazyImport():
"""
TESTS::
sage: from sympy import Matrix # needs sympy
sage: # needs sympy
sage: from sympy import Matrix
sage: import sage.all__sagemath_objects
sage: sage.all__sagemath_objects.foo = Matrix([[1,1], [0,1]]) # needs sympy
sage: lazy_import('sage.all__sagemath_objects', 'foo') # needs sympy
sage: foo.__matmul__(foo) # needs sympy
sage: sage.all__sagemath_objects.foo = Matrix([[1,1], [0,1]])
sage: lazy_import('sage.all__sagemath_objects', 'foo')
sage: foo.__matmul__(foo)
Matrix([
[1, 2],
[0, 1]])
Expand Down
9 changes: 4 additions & 5 deletions src/sage/misc/lazy_string.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -519,25 +519,24 @@ cdef class _LazyString():
EXAMPLES::
sage: # needs sage.libs.pari
sage: # needs sage.rings.finite_rings
sage: from sage.misc.lazy_string import lazy_string
sage: def f(op, A, B):
....: return "unsupported operand parent(s) for %s: '%s' and '%s'" % (op, A, B)
sage: R = GF(5)
sage: S = GF(3)
sage: D = lazy_string(f, '+', R, S)
sage: D
sage: D = lazy_string(f, '+', R, S); D
l"unsupported operand parent(s) for +: 'Finite Field of size 5' and 'Finite Field of size 3'"
sage: D.update_lazy_string(('+', S, R), {})
Apparently, the lazy string got changed in-place::
sage: D # needs sage.libs.pari
sage: D # needs sage.rings.finite_rings
l"unsupported operand parent(s) for +: 'Finite Field of size 3' and 'Finite Field of size 5'"
TESTS::
sage: D.update_lazy_string(None, None) # needs sage.libs.pari
sage: D.update_lazy_string(None, None) # needs sage.rings.finite_rings
Traceback (most recent call last):
...
TypeError: Expected tuple, got NoneType
Expand Down
Loading

0 comments on commit 8cb3795

Please sign in to comment.