-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Determine cause of floating point exception with accelerated __mod__ #3819
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
Comments
hmm wonder if there is a dtype that ne doesn't like or maybe nan with % not supported |
it's very simple to reproduce (and I just opened a numexpr issue). Modulus with zero isn't supported. Check it: arr = np.arange(-5, 5)
# this will cause a floating point exception
ne.evaluate("arr % 0", locals()) Floats don't cause the problem arr = arr.astype(float)
ne.evaluate("arr % 0", locals()) |
good to know.....this should still fallback to the numpy loop in evaluate in any event |
No, you can't catch it, it crashes the Python interpreter completely (see the end of this Travis build - https://travis-ci.org/jtratner/pandas/jobs/7917801 ). That's why in #3765 I've completely removed |
oh....it DOESN't raise a FloatingPointException.....weird....ok...easy enough to not-accelarate (or alternativly you can cast to float64, sending in an additional parm, maybe of course easiest is simply to always cast mod and div to float, then you solve this problem and get truediv for free... but IIRC we decided to push that off..... |
@jreback haha, yeah. Though would you cast it back to int afterwards? Actually, looks like you can just cast the other mod operand to float (so if it's |
we dont' do any casting back on arithmetic ops that are handled thru _arith_ops...(e.g..-,+,/,**,%) |
so, basically, we just wouldn't pass it to On Mon, Jun 10, 2013 at 8:05 AM, jreback notifications@github.com wrote:
|
it occurred to me: except for the issue covered by _fill_zeros, does On Mon, Jun 10, 2013 at 8:07 AM, Jeffrey Tratner
|
they basically upcast if and convert to floats if needed AFAIK |
So, aside from the fill zeros, pandas doesn't change the type of numpy On Mon, Jun 10, 2013 at 8:21 AM, jreback notifications@github.com wrote:
|
I think this i true for the binary arithmetic operators |
For some reason, using numexpr with
%
and zeros causes floating point exceptions. I.e., in this Travis CI test you can see the mysterious floating point exception occur:The exception occurs when
__mod__
is evaluated with str_rep of%
(meaninga_values % b_values
is passed tonumexpr.evaluate
), and it occurs intest_expressions.py
undertest_mixed_floats_arithmetic
andtest_integer_with_zeros
in (for example) jtratner/pandas@e938da2 . Omittingstr_rep
from__mod__
fixes the issues, clearly showing it's occurring with numexpr. Going to investigate more in the future.The text was updated successfully, but these errors were encountered: