Skip to content

Conversation

@AlienAtSystem
Copy link

np.bincount has at some point become extremely selective about its input type, accepting only 'int32' and nothing else.

np.bincount wants 'int32' as type, and accepts no other any more. Since fdir is getting typecast anyway, I just fixed it to constantly cast to the one working one.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 292

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 81.479%

Totals Coverage Status
Change from base Build 291: 0.0%
Covered Lines: 2028
Relevant Lines: 2489

💛 - Coveralls

@mdbartos
Copy link
Owner

mdbartos commented Jun 26, 2020

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)

@AlienAtSystem
Copy link
Author

AlienAtSystem commented Jun 27, 2020

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'

@mdbartos
Copy link
Owner

mdbartos commented Jul 1, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants