DOC: Add 'import numpy as np' to the 'Examples' section of docstrings.
See original GitHub issueIt was recently decided that we would add the explicit import of numpy in the ‘Examples’ section of our docstrings. (See the discussion in https://github.com/scipy/scipy/issues/13049.) Some progress has been made towards doing this consistently throughout SciPy, but there are still many functions and methods that need to be updated.
I created a script called find_missing_import_np.py
that finds functions and methods that are missing the import. Previously stored in a gist, the script is now in my github repo analyze-scipy-code
.
Here is the output when I run it with the SciPy main development branch (6-November-2022):
scipy version 1.10.0.dev0+2152.55452d1
Found 0 objects missing 'import numpy as np'
🎉
Issue Analytics
- State:
- Created a year ago
- Comments:23 (22 by maintainers)
Top Results From Across the Web
Example NumPy Style Python Docstrings
coding: utf-8 -*- """Example NumPy style docstrings. This module demonstrates documentation as specified by the `NumPy Documentation HOWTO`_.
Read more >A Guide to NumPy Documentation
For example, Sphinx will extract the Parameters section from your docstring and convert it into a field list.
Read more >How to Write NumPy-Style Docstrings | Python in Plain English
import numpy as np ... The docstring in NumPy style consists of several sections. ... Then add a section describing the parameters and...
Read more >pandas docstring guide - Python-Sprints
Section 7: Examples¶ · Import required libraries (except numpy and pandas ) · Create the data required for the example · Show a...
Read more >Documenting Python APIs with docstrings
(Note: one-line docstrings are rarely used for public APIs, see Numpydoc sections in docstrings.) An example of a multi-paragraph docstring: """Sum numbers ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @BassCoder2808, but in fact I am about to submit a pull request to finish these off. The main purpose of the pull request will be to fix a bunch of other issues in the docstrings in
scipy.signal
, but as long as I’m fixing docs, I might as well fix the few remaining cases of missingimport numpy as np
.Just to be clear: https://github.com/scipy/scipy/pull/17115 is almost done, and after that is merged, there won’t be a lot of examples left to fix.