question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: Add 'import numpy as np' to the 'Examples' section of docstrings.

See original GitHub issue

It 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:closed
  • Created a year ago
  • Comments:23 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
WarrenWeckessercommented, Nov 5, 2022

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 missing import numpy as np.

1reaction
WarrenWeckessercommented, Oct 10, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found