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
isprime should error on floats #26489
Comments
What SymPy code are you using that gives you this? SymPy does not have a function called
|
Yup! I was using floats, not integers! Thanks! |
I was about to suggest just that. It might be better if isprime just errored if the input is a float. Returning False for an integral float is confusing. |
This would be trivial to change, by the way. Just delete these lines sympy/sympy/ntheory/primetest.py Lines 672 to 673 in e89ee93
Looks like this comes from #9670. It's good for the assumptions to return False here, but the isprime() function would be better raising an exception. |
I agree with the change. |
You'll also need to update the code in Q.isprime to catch the exception and continue to give False for floats. |
Would it be better if instead of an error we internally converted them to integers(if the value was integral) or is there any particular reason to be raising an error on those values as well? |
You can see the discussion on the old PR I linked to on why integral floats aren't considered prime. |
I tried the method given in the documentation since i wanted to take a look at the working SYMPY_DEBUG=True bin/isympy but in the sympy interactive terminal I still just get the output In [1]: ask(Q.prime(2))
Out[1]: True Can someone please inform me about what I am doing wrong. |
There's just not any debug output configured for ask. You'll need to just dig into the source code to see where |
I was making a calculator and ran into an issue. 2 in not prime?? What!? I looked up tutorials, but still. 2 = false or not prime please help!
The text was updated successfully, but these errors were encountered: