Open AlienAtSystem opened 4 years ago
Totals | |
---|---|
Change from base Build 291: | 0.0% |
Covered Lines: | 2028 |
Relevant Lines: | 2489 |
Interesting. What version of numpy are you using? I'm on 1.18.3 and the following still seem to work:
import numpy as np
x = np.random.randint(100, size=1000, dtype=np.int64)
_ = np.bincount(x)
x = np.random.randint(100, size=1000, dtype=np.int16)
_ = np.bincount(x)
x = np.random.randint(100, size=1000, dtype=np.uint16)
_ = np.bincount(x)
I'm using numpy 1.19.0 in Python 3.8.3 in an Ipython 7.15.0 console and get the following:
import numpy as np
x = np.random.randint(100, size=1000, dtype=np.int64)
_ = np.bincount(x)
x = np.random.randint(100, size=1000, dtype=np.int16)
_ = np.bincount(x)
x = np.random.randint(100, size=1000, dtype=np.uint16)
_ = np.bincount(x)
Traceback (most recent call last):
File "<ipython-input-1-015b31e77d51>", line 3, in <module>
_ = np.bincount(x)
File "<__array_function__ internals>", line 5, in bincount
TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
Just tested again with numpy 1.19.0, python 3.8.3 and ipython 7.13.0. Still no exception on my side.
I'm running on manjaro linux using the openblas library as the backend (you can check your backend using np.show_config()
).
Is it possible you are using a 32-bit version of either python/numpy or got 64/32 bit versions mixed together?
np.bincount has at some point become extremely selective about its input type, accepting only 'int32' and nothing else.