-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Enforce dtype for randint singletons #7254
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
Conversation
@charris : +1 for the |
I think it makes sense to return the numpy type if the dtype keyword was specified. To preserve backwards compatibility with 1.10 we could still return a Python int if neither size nor dtype are specified, I suppose. But that sounds like an extra complication that will almost never affect anyone, and if users know randint returns arrays of What is the test error you get in Big kudos to you and @charris by the way for all the improvements to the |
@ahaldane : Thank you! Though I think @charris should get extra big kudos since he was the first person to successfully implement it into the codebase 😄 I agree that backwards compatibility need not necessarily be preserved in such a case since I would imagine the most common use case is to generate arrays of data. Also, as the Regarding the test failures, the tests fail, at least locally, due to warnings about |
Added the 1.11.0 milestone since, if this goes in, we might as well start right :) |
Is there anything else people would like to add with regards to this change? Otherwise, it should be good to merge. |
I was still a little worried about the unit test you modified, but I convinced myself it's OK. That test is hardcoded in C to expect a Python int for some reason, so it's not a more general problem in numpy. I'll merge in a few hours if there are no more comments. |
@ahaldane : Thanks for taking the time to look at several of my PR's! |
BUG: Enforce dtype for randint singletons
Thanks @gfyoung |
Addresses issue in #7203 in which specifying the
dtype
for a single integer was not being respected. This PR makes therandint
API consistent across allsize
specifications in that only numbers ofnumpy
dtypes are returned, which already occurs when you generate arrays usingrandint
.