sympy-live
sympy-live copied to clipboard
Bug with Sphinx extension in tutorial
At http://docs.sympy.org/latest/tutorial/basic_operations.html, if you run the block
>>> str_expr = "x**2 + 3*x - 1/2"
>>> expr = sympify(str_expr)
>>> expr
x**2 + 3*x - 1/2
>>> expr.subs(x, 2)
19/2
It runs as
>>> expr = sympify(str_expr)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'str_expr' is not defined
>>> expr
sin(x)
>>> expr.subs(x, 2)
sin(2)
and if you run
>>> import numpy
>>> a = numpy.arange(10)
>>> expr = sin(x)
>>> f = lambdify(x, expr, "numpy")
>>> f(a)
[ 0. 0.84147098 0.90929743 0.14112001 -0.7568025 -0.95892427
-0.2794155 0.6569866 0.98935825 0.41211849]
it runs as
>>> a = numpy.arange(10)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'numpy' is not defined
>>> expr = sin(x)
>>> f = lambdify(x, expr, "numpy")
>>> f(a)
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'a' is not defined
It's not running the first line for some reason.