Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2545 by [email protected]: lambdify expression containing pi
http://code.google.com/p/sympy/issues/detail?id=2545

Lambdify of expressions that contain for example a pi
does not work as expected. Here is a small example:

# Create an expression
x = sympy.Symbol("x")
y = x**2 + sympy.pi

# lamdbfiy and specify "numpy" as we want to do numerics
# and are *only* interersted in floating point numbers later
f = sympy.lambdify(x, y, "numpy")

# Test:
In [9]: f(2)
Out[9]: pi + 4

# Hmm, suspicious "pi" here

# Oh and the type is something really not suitable
# for further numerical computations ...

In [11]: type(f(2))
Out[11]: <class 'sympy.core.add.Add'>

# Let's test with a numpy array as input

In [13]: u = numpy.linspace(-2,2,10)

In [14]: f(u)
Out[14]:
array([pi + 4.0, 2.41975308641975 + pi, 1.23456790123457 + pi,
       0.444444444444445 + pi, 0.0493827160493828 + pi,
       0.0493827160493828 + pi, 0.444444444444444 + pi,
1.23456790123457 + pi, 2.41975308641975 + pi, pi + 4.0], dtype=object)

# It get's even worse! We would like to have a
# dtype of float or something linke that but not "object" arrays.

# At least the type f(u) is a ndarray

In [15]: type(f(u))
Out[15]: <type 'numpy.ndarray'>

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to