-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
DOC: add Numpy import to examples #17115
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
Issue16759
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.
These all look fine to me. I haven't looked into the files to see if there are any other examples that need the import line, but I did verify that all of those listed here actually use numpy for the example.
>>> import numpy as np | ||
>>> import matplotlib.pyplot as plt | ||
>>> from numpy.fft import fft, ifft, fftshift, fftfreq |
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.
Minor nit: maybe we want to keep np.fft
here instead of importing again? Not sure if that would be too verbose for the code, though.
scipy/signal/_signaltools.py
Outdated
>>> import numpy as np | ||
>>> from scipy import signal | ||
>>> from numpy.random import default_rng |
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.
Same comment as above: might as well have one import?
scipy/signal/_signaltools.py
Outdated
>>> import numpy as np | ||
>>> from scipy import signal | ||
>>> from numpy.random import default_rng |
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.
Again, might be simplified.
In cases where the example has code like this
I agree with @melissawm's suggestion to adjust to code to have just one
This is consistent with most other uses of The one other case like this involves
I think we can leave that as is in this pull request. In a separate pull request, we could change that to import from |
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.
I think you missed a few fixes in the last update. I have some changes requested, otherwise this looks good. There are a few places where the import of numpy is not at the beginning, but that is still a topic of discussion, so not a problem.
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.
There is one change needed. I'll push that, let the tests run again, and merge if that goes well.
Requested changes have been made.
The 3.11-dev job installs numpy from the main development branch. The failures are the result of numpy/numpy#22385, and not related to this pull request. |
Merged. Thanks @BassCoder2808! |
As decided in scipygh-13049, add 'import numpy as np' to the examples where needed. This change updates most of the functions and classes listed in scipygh-16759.
Reference issue
#16759
What does this implement/fix?
Added import numpy as np to docstring examples in every file as per the script https://gist.github.com/WarrenWeckesser/f81e1d6453a639c745da50746d7078fb
Additional information