Skip to main content
# npdoc.py

I do a lot of work entirely in an IPython notebook and it can be annoying to switch back and forth from a browser to the command line to look up function usage. I therefore wrote this little utility. Given a numpy function name, it will look up the function's source on GitHub, and parse the usage comment at the top of the function.

This code requires the BeautifulSoup 4 library, which is readily pip'd.

Here's an example:

```
>> import npdoc

>> npd('meshgrid')

>> Return coordinate matrices from coordinate vectors.

Make N-D coordinate arrays for vectorized evaluations of
N-D scalar/vector fields over N-D grids, given
one-dimensional coordinate arrays x1, x2,..., xn.

.. versionchanged:: 1.9
1-D and 0-D cases are allowed.

...
```
(Not showing the full output because there's a lot)

You can also specify to only see the first or last lines with the ```nl``` argument. A positive argument gives the first N lines:
```
>> import npdoc

>> npd('meshgrid', nl = 4)

>> Return coordinate matrices from coordinate vectors.

Make N-D coordinate arrays for vectorized evaluations of
N-D scalar/vector fields over N-D grids, given
```

And a negative argument gives the last N lines:
```
>> import npdoc

>> npd('meshgrid', nl = -4)

>> >>> y = np.arange(-5, 5, 0.1)
>>> xx, yy = np.meshgrid(x, y, sparse=True)
>>> z = np.sin(xx**2 + yy**2) / (xx**2 + yy**2)
>>> h = plt.contourf(x,y,z)
```

Note: in the case of the base NumPy functions, like ```np.array```, the source is more difficult to get to and to parse (those functions are written in C, too), so in that case, ```npd()``` will just open a browser with the formatted webpage. If you just want to go straight to the formatted webpage anyway, just do ```npd('meshgrid', browser = True)```.

Release files for npdoc 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for npdoc 1.0.1
File Size Uploaded
npdoc-1.0.1.tar.gz 2.0 kB Details

Release files / npdoc-1.0.1.tar.gz

Download URL npdoc-1.0.1.tar.gz
Size 2.0 kB
Tags Source
SHA-256 checksum
How to use checksums
80649f4afad548f0fa666b4d122ddcd8284ac2dce3b2a1dee0c66cae707aad69
BLAKE2b-256 checksum
How to use checksums
a1b22e0ddedbe5cdcbe825708142fe858fa179fe3e61ac514ececd00ce9333fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page