-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Adjust typing for readded np.long
#25039
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
57c136a
to
28a696b
Compare
This is getting very tedious and opaque in the intp as default PR. The test are failing here though, would be great to get some of these fixes out of the way to hopefully get somewhere in that PR. |
…mall bug Also, fixes a small issue, that the type[int] and type[bool] are special and any other paths were actually just broken.
e29b21f
to
59ed171
Compare
59ed171
to
979cd87
Compare
@BvB93 moving this over here for now. For some reason, I have to use The big churn here, is that randint/integers was typed incorrectly. We return int/bool only if dtype is exactly that (the code is a bit unclear, I fixed that also). Ideally, this should make it much easier to make progress on the other PR once finished. Locally, the tests were passing, but of course I am not 100% sure that will translate to windows. |
Btw. I am a bit surprised, but the reveal tests don't actually check that the revealed type matches the run-time result? Because the random ones were never actually correct here. |
@@ -796,7 +796,7 @@ cdef class RandomState: | |||
else: | |||
raise TypeError('Unsupported dtype %r for randint' % _dtype) | |||
|
|||
if size is None and dtype in (bool, int): | |||
if size is None and (dtype is bool or dtype is int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (same in generator) is the only actual change here, because this is just wrong and including it here clarifies the typing side fixes. We already return NumPy scalars when relevant and dtype(...)
doesn't actually work for arbitrary dtype-likes (could be strings, or dtype instances).
OK, mypy tests are passing. I would like to finally unblock gh-24224, so would appreciate a review. |
Currently looking at #24224 as well; turns out an |
Yeah, I thought reordering things might help with that one, but I am not sure it is a reasonable thing and just returning to the old platform dependent version seems OK also. |
Either is fine tbh, as long as it just stops blocking your PR as the typing failures have been a hold up for long enough now IMO.
Just a bit more context: the reveal type tests check, using |
@BvB93 do you want to have a closer look at this? Otherwise, I am tempted to push things through and consider it a follow-up review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to push for now; I'm hoping to do a more thorough review of the 2.0-related typing changes soon (including a few of the leftover long
-related points; xref #25048), but I don't expect that will be until later this week.
Let's pull this in to unblock changing the default integer on windows. |
Connected to #24922 and #24224
Hi @seberg,
I just started working on it but I wanted to open a PR for adjusting typing after reintroducing
np.long
. Let's continue the discussion here!