Skip to content

Commit

Permalink
Merge branch 'sd117_more_optional_doctest_tags' into t/32601/modulari…
Browse files Browse the repository at this point in the history
…zation_of_sagelib__break_out_a_separate_package_sagemath_standard_no_symbolics
  • Loading branch information
Matthias Koeppe committed Mar 8, 2023
2 parents c63db14 + 7e89a0d commit 716d750
Show file tree
Hide file tree
Showing 315 changed files with 9,955 additions and 9,244 deletions.
892 changes: 446 additions & 446 deletions src/sage/arith/misc.py

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/sage/calculus/riemann.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,10 +1190,10 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
EXAMPLES::
sage: from sage.calculus.riemann import complex_to_spiderweb
sage: import numpy
sage: zval = numpy.array([[0, 1, 1000],[.2+.3j,1,-.3j],[0,0,0]],dtype = numpy.complex128)
sage: deriv = numpy.array([[.1]],dtype = numpy.float64)
sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,False,0.001)
sage: import numpy # optional - numpy
sage: zval = numpy.array([[0,1,1000], [.2+.3j,1,-.3j], [0,0,0]], dtype=numpy.complex128) # optional - numpy
sage: deriv = numpy.array([[.1]],dtype = numpy.float64) # optional - numpy
sage: complex_to_spiderweb(zval, deriv, deriv, 4, 4, [0,0,0], 1, False, 0.001) # optional - numpy
array([[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],
Expand All @@ -1206,7 +1206,7 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
[1., 1., 1.],
[1., 1., 1.]]])
sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,True,0.001)
sage: complex_to_spiderweb(zval, deriv, deriv, 4, 4, [0,0,0], 1, True, 0.001) # optional - numpy
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]],
Expand Down Expand Up @@ -1280,13 +1280,13 @@ cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
EXAMPLES::
sage: from sage.calculus.riemann import complex_to_rgb
sage: import numpy
sage: complex_to_rgb(numpy.array([[0, 1, 1000]], dtype = numpy.complex128))
sage: import numpy # optional - numpy
sage: complex_to_rgb(numpy.array([[0, 1, 1000]], dtype=numpy.complex128)) # optional - numpy
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]]])
sage: complex_to_rgb(numpy.array([[0, 1j, 1000j]], dtype = numpy.complex128))
sage: complex_to_rgb(numpy.array([[0, 1j, 1000j]], dtype=numpy.complex128)) # optional - numpy
array([[[1. , 1. , 1. ],
[0.52779177, 1. , 0.05558355],
[0.08650622, 0.17301243, 0. ]]])
Expand Down
80 changes: 40 additions & 40 deletions src/sage/calculus/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,98 +102,98 @@
And here are some actual tests of sympy::
sage: from sympy import Symbol, cos, sympify, pprint
sage: from sympy.abc import x
sage: from sympy import Symbol, cos, sympify, pprint # optional - sympy
sage: from sympy.abc import x # optional - sympy
::
sage: e = (1/cos(x)^3)._sympy_(); e
sage: e = (1/cos(x)^3)._sympy_(); e # optional - sympy
cos(x)**(-3)
sage: f = e.series(x, 0, int(10)); f
sage: f = e.series(x, 0, int(10)); f # optional - sympy
1 + 3*x**2/2 + 11*x**4/8 + 241*x**6/240 + 8651*x**8/13440 + O(x**10)
And the pretty-printer. Since unicode characters are not working on
some architectures, we disable it::
sage: from sympy.printing import pprint_use_unicode
sage: prev_use = pprint_use_unicode(False)
sage: pprint(e)
sage: from sympy.printing import pprint_use_unicode # optional - sympy
sage: prev_use = pprint_use_unicode(False) # optional - sympy
sage: pprint(e) # optional - sympy
1
-------
3
cos (x)
sage: pprint(f)
sage: pprint(f) # optional - sympy
2 4 6 8
3*x 11*x 241*x 8651*x / 10\
1 + ---- + ----- + ------ + ------- + O\x /
2 8 240 13440
sage: pprint_use_unicode(prev_use)
sage: pprint_use_unicode(prev_use) # optional - sympy
False
And the functionality to convert from sympy format to Sage format::
sage: e._sage_()
sage: e._sage_() # optional - sympy
cos(x)^(-3)
sage: e._sage_().taylor(x._sage_(), 0, 8)
sage: e._sage_().taylor(x._sage_(), 0, 8) # optional - sympy
8651/13440*x^8 + 241/240*x^6 + 11/8*x^4 + 3/2*x^2 + 1
sage: f._sage_()
sage: f._sage_() # optional - sympy
8651/13440*x^8 + 241/240*x^6 + 11/8*x^4 + 3/2*x^2 + Order(x^10) + 1
Mixing SymPy with Sage::
sage: import sympy
sage: var("x")._sympy_() + var("y")._sympy_()
sage: import sympy # optional - sympy
sage: var("x")._sympy_() + var("y")._sympy_() # optional - sympy
x + y
sage: o = var("omega")
sage: s = sympy.Symbol("x")
sage: t1 = s + o
sage: t2 = o + s
sage: type(t1)
sage: o = var("omega") # optional - sympy
sage: s = sympy.Symbol("x") # optional - sympy
sage: t1 = s + o # optional - sympy
sage: t2 = o + s # optional - sympy
sage: type(t1) # optional - sympy
<class 'sympy.core.add.Add'>
sage: type(t2)
sage: type(t2) # optional - sympy
<class 'sage.symbolic.expression.Expression'>
sage: t1, t2
sage: t1, t2 # optional - sympy
(omega + x, omega + x)
sage: e=sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x"))
sage: type(e)
sage: e = sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x")) # optional - sympy
sage: type(e) # optional - sympy
<class 'sympy.core.add.Add'>
sage: e
sage: e # optional - sympy
sin(y) + cos(x)
sage: e=e._sage_()
sage: type(e)
sage: e=e._sage_() # optional - sympy
sage: type(e) # optional - sympy
<class 'sage.symbolic.expression.Expression'>
sage: e
sage: e # optional - sympy
cos(x) + sin(y)
sage: e = sage.all.cos(var("y")**3)**4+var("x")**2
sage: e = e._sympy_()
sage: e
sage: e = sage.all.cos(var("y")**3)**4+var("x")**2 # optional - sympy
sage: e = e._sympy_() # optional - sympy
sage: e # optional - sympy
x**2 + cos(y**3)**4
::
sage: a = sympy.Matrix([1, 2, 3])
sage: a[1]
sage: a = sympy.Matrix([1, 2, 3]) # optional - sympy
sage: a[1] # optional - sympy
2
::
sage: sympify(1.5)
sage: sympify(1.5) # optional - sympy
1.50000000000000
sage: sympify(2)
sage: sympify(2) # optional - sympy
2
sage: sympify(-2)
sage: sympify(-2) # optional - sympy
-2
TESTS:
This was fixed in Sympy, see :trac:`14437`::
sage: from sympy import Function, Symbol, rsolve
sage: u = Function('u')
sage: n = Symbol('n', integer=True)
sage: f = u(n+2) - u(n+1) + u(n)/4
sage: expand(2**n * rsolve(f,u(n)))
sage: from sympy import Function, Symbol, rsolve # optional - sympy
sage: u = Function('u') # optional - sympy
sage: n = Symbol('n', integer=True) # optional - sympy
sage: f = u(n+2) - u(n+1) + u(n)/4 # optional - sympy
sage: expand(2**n * rsolve(f,u(n))) # optional - sympy
2*C1*n + C0
"""
30 changes: 15 additions & 15 deletions src/sage/categories/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,24 @@ cdef class InverseAction(Action):
EXAMPLES::
sage: V = QQ^3
sage: v = V((1, 2, 3))
sage: V = QQ^3 # optional - sage.modules
sage: v = V((1, 2, 3)) # optional - sage.modules
sage: cm = get_coercion_model()
sage: a = cm.get_action(V, QQ, operator.mul)
sage: a
sage: a = cm.get_action(V, QQ, operator.mul) # optional - sage.modules
sage: a # optional - sage.modules
Right scalar multiplication by Rational Field on Vector space of dimension 3 over Rational Field
sage: ~a
sage: ~a # optional - sage.modules
Right inverse action by Rational Field on Vector space of dimension 3 over Rational Field
sage: (~a)(v, 1/3)
sage: (~a)(v, 1/3) # optional - sage.modules
(3, 6, 9)
sage: b = cm.get_action(QQ, V, operator.mul)
sage: b
sage: b = cm.get_action(QQ, V, operator.mul) # optional - sage.modules
sage: b # optional - sage.modules
Left scalar multiplication by Rational Field on Vector space of dimension 3 over Rational Field
sage: ~b
sage: ~b # optional - sage.modules
Left inverse action by Rational Field on Vector space of dimension 3 over Rational Field
sage: (~b)(1/3, v)
sage: (~b)(1/3, v) # optional - sage.modules
(3, 6, 9)
sage: c = cm.get_action(ZZ, list, operator.mul)
Expand Down Expand Up @@ -392,11 +392,11 @@ cdef class InverseAction(Action):
Check that this action can be pickled (:trac:`29031`)::
sage: V = QQ^3
sage: v = V((1, 2, 3))
sage: cm = get_coercion_model()
sage: a = cm.get_action(V, QQ, operator.mul)
sage: loads(dumps(~a)) is not None
sage: V = QQ^3 # optional - sage.modules
sage: v = V((1, 2, 3)) # optional - sage.modules
sage: cm = get_coercion_model() # optional - sage.modules
sage: a = cm.get_action(V, QQ, operator.mul) # optional - sage.modules
sage: loads(dumps(~a)) is not None # optional - sage.modules
True
"""
return (type(self), (self._action,))
Expand Down
Loading

0 comments on commit 716d750

Please sign in to comment.