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 performs unwanted integer division when used with with sympy.sqrt and modules='numexpr' #9871
Comments
I would like to fix it. |
Do we need to be specific while printing ?I mean is it necessary to return a value of type 'int' if the input is of type 'int'. |
Not sure what this means.
The behavior should match the lambdify backend. If it is using numpy, for example, then if should do the same thing numpy functions do to ints. |
@moorepants i tried running the code through python debugger but i couldn't access the source code being executed.. i want to fix this bug. can u suggest something ? |
You can use the lambdarepr printer to see what source code is generated. |
@moorepants can you tell exactly how to use lambdarepr !! i somehow want to access the code being accessed by the line print f_numexpr(xn,yn,zn) , the debugger cannot access the code for this line !! how should we go about solving this !! |
@moorepants The problem is with necompile.py in numexpr repo where the default value of truediv is set to False, Because of which integer division is taking place.. |
Maybe this needs to be set to true or false depending on the Python version? |
It seems numpy and numexpr handling error part .Am I right ? |
@moorepants did u check it with other versions of python ? |
Nope. |
@moorepants I think a issue must be raised in numexpr to fix this ?and this should be closed !! because ultimately the bug is numexpr repo. |
If you think that is the case, then open an issue there. |
The lambdify function does not correctly handle integer vs. floating point division in conjunction with sympy's native sqrt function and the numexpr module. This bug occurs in Python 2.7; Python 3 has not been tested. The following code illustrates the problem:
which outputs:
Floating point division should occur in all 4 test cases, however integer division is being performed when sp.sqrt and the numpexpr module are used.
The text was updated successfully, but these errors were encountered: