-
Notifications
You must be signed in to change notification settings - Fork 110
BUG: nansum platform overflow #83
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
These issues are a pain. The target for bn.nansum is np.sum. For the example you give, bn.nansum behaves like np.sum, at least on my 64-bit linux system. |
agreed! they all work on 64-bit correctly (because the return dtype is the platform dtype, e.g. np.int64 or np.float64) (above examples are on a 32-bit linux platform) the problem ONLY occurs on a 32-bit platform where the default return type is np.int32/np.float64 and it overflows |
Can you show me an example where bn.nansum and np.sum give a different answer? |
oh i c what you mean; I think they give the same result
numpy guys says that the user is responsible for this (e.g. to pass a capable dtype in) I fixed it by doing this: https://github.com/pydata/pandas/pull/6954/files |
Ugh, your fix looks like it was painful to make. bn.nansum does not support all of the input parameters of np.sum :( |
hah....! I think to avoid issues, you should simply always use 64 bit dtypes or > when their is a possibility of overflow (and then cast back if necessary / possible) to the correct return type of scalar on 64-bit this is not an issue at all; and on 32-bit it is ONLY an issue when the operation overflows numpy is wrong (though at the very least they should raise OverFlow) |
this is on 32-bit linux
on 64-bit the the int dtypes work correctly
stems from here
numpy/numpy#4638
pandas-dev/pandas#6915
workaround with numpy is to do arithmetic in highest dtype, e.g.
values.sum(dtype='float64')
then cast backThe text was updated successfully, but these errors were encountered: