-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
ENH: Add typing for RandomState #18433
Conversation
Closes #17103. |
I think that it would be wise to add a few typing tests for There are currently three types of typing tests:
|
5154739
to
b57a01a
Compare
b57a01a
to
96c8110
Compare
df17793
to
36bd237
Compare
At first glance this PR looks just fine; I'll give it a final once-over later this week. |
6bb887b
to
70e7bd5
Compare
@BvB93 I'm struggling with functions that have outputs These are all Windows or Linux 32 tests. |
@BvB93 I found your typing template in the tests, e.g. |
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.
@bashtage it took a bit longer than expected but I've made some time to go through the PR.
There are a few comments but overall I'd say it's looking pretty good.
If you ever stumble upon a common pattern that you feel might be useful to have as an alias, |
2b00243
to
1e3d5e0
Compare
Add typing for RandomState Small fixes to Generator's typing
Add tests for lower level components Correct errors found in testing Improve specificity of tests Other small fixes to docs and typing
Add tests Fix related bugs Improve specificity of definitions
Add further tests for functions that accept out and dtype arguments
Bring over changes from Generator to RandomState where appropriate Remove attributes not in RandomState
Clean unnecessary definitions Fix small typing errors
Remove incorrect variable name in randint
1e3d5e0
to
d4c1236
Compare
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.
LGTM
@@ -8,57 +8,58 @@ from numpy.random._philox import Philox as Philox | |||
from numpy.random._sfc64 import SFC64 as SFC64 | |||
from numpy.random.bit_generator import BitGenerator as BitGenerator | |||
from numpy.random.bit_generator import SeedSequence as SeedSequence | |||
from numpy.random.mtrand import ( |
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.
Does importing here work differently than regular python that we need to do "from x import y as y" and not "from x import y"? If so, it would be nice to get a comment explaining this for the next time I ask the same question
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.
Taking @BvB93 's word, yes. If you want a symbol reexported, then you need to import X as X.
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.
Per PEP 484:
Modules and variables imported into the stub are not considered exported from the stub unless the import uses the
import ... as ...
form or the equivalentfrom ... import ... as ...
form. (UPDATE: To clarify, the intention here is that only names imported using the form X as X will be exported, i.e. the name before and after as must be the same.)
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.
Thanks. I probably asked this last time I looked at this code.
Thanks @bashtage |
Add typing for RandomState
Small fixes to Generator's typing