Type hints for NumPy.
Project description
⚠ This describes the 2.0.0 alpha release.
For the latest stable release, pick 1.4.4
💡 Type hints for NumPy
💡 Extensive dynamic type checks for dtypes and shapes of arrays
💡 Limited static type checks with MyPy
Example of a hinted function with nptyping
:
>>> from nptyping import NDArray, Int, Shape
>>> def func(arr: NDArray[Int, Shape["2, 2"]]) -> None:
... pass
Example of instance checking:
>>> from numpy import array
>>> isinstance(array([[1, 2], [3, 4]]), NDArray[Int, Shape["2, 2"]])
True
>>> isinstance(array([[1., 2.], [3., 4.]]), NDArray[Int, Shape["2, 2"]])
False
>>> isinstance(array([1, 2, 3, 4]), NDArray[Int, Shape["2, 2"]])
False
Here is an example of how detailed expressions can become with nptyping
:
def plan_route(locations: NDArray[Float, Shape["[from, to], [x, y]"]]) -> NDArray[Float, Shape["* stops, [x, y]"]]:
...
More examples can be found in the documentation.
Installation
pip install nptyping
Documentation
-
User documentation
The place to go if you are using this library. -
Release notes
To see what's new, check out the release notes. -
Contributing
If you're interested in developing along, find the guidelines here. -
Licence
If you want to check out how open source this library is.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for nptyping-2.0.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 157490988e0ede5f47c0edc091211aa17600c7af2c39707e7764b17685005e23 |
|
MD5 | 092c1c59a4b7cde338212e6401f9cc34 |
|
BLAKE2b-256 | 68bd84669be2eb23ba32caf2b423de4c3eb7ba3656525cde0fd1d5fdbbede73e |