Skip to main content

In-notebook NumPy man pages

Project description

# 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)```.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

npdoc-1.0.1.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file npdoc-1.0.1.tar.gz.

File metadata

  • Download URL: npdoc-1.0.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for npdoc-1.0.1.tar.gz
Algorithm Hash digest
SHA256 80649f4afad548f0fa666b4d122ddcd8284ac2dce3b2a1dee0c66cae707aad69
MD5 95d23671916d9ff3d837f0f49814db11
BLAKE2b-256 a1b22e0ddedbe5cdcbe825708142fe858fa179fe3e61ac514ececd00ce9333fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page