Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambdify throws error with abs #9474

Closed
moorepants opened this issue Jun 5, 2015 · 4 comments · Fixed by #10499
Closed

lambdify throws error with abs #9474

moorepants opened this issue Jun 5, 2015 · 4 comments · Fixed by #10499

Comments

@moorepants
Copy link
Member

This is from #7767 and there is a potential fix in #7779.

Just found a bug in lambdify

k = symbols('k', complex=True)
lambdify([k], abs(k**2))(10.01+0.1j)

throws


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-144-4ad0dd2e940e> in <module>()
      1 k = symbols('k', complex=True)
----> 2 lambdify([k], abs(k**2))(10.01+0.1j)

/usr/lib64/python2.7/site-packages/numpy/__init__.pyc in <lambda>(_Dummy_82)

TypeError: can't convert complex to float

using sympy.Abs leads to the same exception.

@Shekharrajak
Copy link
Member

What is the difference between k and [k] ?

@moorepants
Copy link
Member Author

[k] is a list of one element, k.

@Shekharrajak
Copy link
Member

It returns correct answer if we use numpy module :

lambdify([k], abs(k**2),"numpy")(10.01+0.1j)
100.2101

@twmr
Copy link
Contributor

twmr commented Jan 30, 2016

Yes, but not if we don't use the numpy module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants