Skip to content
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

Fix for bincount type touchyness #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

None yet

3 participants