-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Make numpy an optional dependency in utilities\seed.py
#20055
Make numpy an optional dependency in utilities\seed.py
#20055
Conversation
for more information, see https://pre-commit.ci
utilities\seed.py
i accidently pushed the test file also. so I deleted it
I accidently push the test file also with the PR. I have deleted the file though. |
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.
Yeah this is great, exactly what we need.
…h/pytorch-lightning into seed_numpy_dependency
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #20055 +/- ##
=======================================
Coverage 90% 90%
=======================================
Files 266 266
Lines 22948 22961 +13
=======================================
+ Hits 20678 20690 +12
- Misses 2270 2271 +1 |
Hi @awaelchli. I was working on the remaining issue : in the comment : i want to ask that according to what I have understood reading the code is that the code below already checking numpy is present or not in the code below :
My question is that if we already have a Numpy checking condition, is there a need to add another conditional statement to check whether numpy is available or not ? |
@01AbhiSingh Yes there is still some work needed there. But it's much easier than the seed work here. if _NUMPY_AVAILABLE:
import numpy as np
if isinstance(params[k], (np.bool_, np.integer, np.floating)):
params[k] = params[k].item() For this one, please send a separate PR, and we can discuss any additional challenges there :) |
I will push this in a new PR. What about this current PR ? Do I need to change anything in this current one or is it's all good ? |
faab971
to
b33e37a
Compare
utilities\seed.py
utilities\seed.py
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.
Great work @01AbhiSingh!
I also finally found the time to put together the alternative implementation for the seed sequence generator that was needed to replace the numpy implementation. I committed that to this branch directly and added a simple test.
It took me a little time to understand the difference between the code changes you made and my code change in the seed generation method lol . Definitely some high quality code I can learn a lot from. |
What does this PR do?
Part of #16649
Before submitting
PR review
Numpy no longer a required dependency in
utilites\seed.py
.Made the following changes in code :
Below is the test I ran to ensure that numpy is an optional dependency now and all the functions are doing what they are supposed to do without numpy.
tagging @awaelchli for better visibility.
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20055.org.readthedocs.build/en/20055/