You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing some calculations I discover this unexpected behavior related with dtypes. I hope some of you can point me if this is a bug or I'm doing
something wrong.
Reproducing code example:
Here is a minimal peace of my code which tries to reproduce the problem:
importnumpyasnp# VERSIONS USEDnp.__version__# '1.18.1'np.__version__# '1.19.0'x=731965.048356481480000000000000000000x_arr=np.array([x])
big_int=86400000000000cnst=719529# THIS WORKSarr1= (x_arr-cnst) *big_intout1=arr1.astype("datetime64[ns]")
# THIS FAILSarr2=x_arr*big_int-cnst*big_intout2=arr2.astype("datetime64[ns]")
# WORKAROUNDbig_int=86400000000000.# NOW IS A FLOATarr3=x_arr*big_int-cnst*big_intout3=arr3.astype("datetime64[ns]")
MWE
Here some code that I use for debugging a minimal reproducible example that
shows this unexpected behavior.
The text was updated successfully, but these errors were encountered:
mmngreco
changed the title
Unexpected behavior when an array is subtracted from a very large integer.
Unexpected behavior when an array of floats is subtracted from a very large integer.
Jun 25, 2020
This is a known issue, there should be a few duplicates around in recent past also. The problem is that when NumPy encounters a Python integers it will try the dtypes:
long (np.int_) – on many systems identical to np.int64
np.int64
np.uint64
object
You can do even more fun things if you mix in integers that go to unsigned... I will probably propose to deprecate once my other PR is in, I think. Not sure we will actually do it, but getting random types has lots of traps, in almost all cases uses do alraedy get the default integer (whatever that is, int32, or int64). Anyway, closing as duplicate of: gh-16287
Doing some calculations I discover this unexpected behavior related with
dtypes
. I hope some of you can point me if this is a bug or I'm doingsomething wrong.
Reproducing code example:
Here is a minimal peace of my code which tries to reproduce the problem:
MWE
Here some code that I use for debugging a minimal reproducible example that
shows this unexpected behavior.
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: