nptyping
Type hints for Numpy!
Installation
pip install nptyping
Usage
Use the nptyping type hints like the regular type hints from typing:
from nptyping import Array
def func1(arr: Array[int]): # A numpy.ndarray that contains numbers
...
You can also define the shape of an array:
Array[str, 3, 2] # 3 rows and 2 columns
Array[str, 3] # 3 rows and an undefined number of columns
Array[str, 3, ...] # 3 rows and an undefined number of columns
Array[str, ..., 2] # an undefined number of rows and 2 columns
Heterogeneous arrays are supported as well:
Array[int, float, str] # int, float and str on columns 1, 2 and 3 resp.
Array[int, float, str, ...] # int, float and str on columns 1, 2 and 3 resp.
Array[int, float, str, 3] # int, float and str on columns 1, 2 and 3 resp. and with 3 rows
nptyping also supports instance checks:
import numpy as np
from nptyping import Array
arr = np.array([[1, 2],
[3, 4],
[5, 6]])
isinstance(arr, Array[int, 3, 2]) # True
isinstance(arr, Array[str, 3, 2]) # False
isinstance(arr, Array[int, 3, ...]) # True
isinstance(arr, Array[int, 3, 6]) # False
Also for heterogeneous arrays:
import numpy as np
from nptyping import Array
arr = np.array([(1, 2.0, '3'),
(4, 5.0, '6')],
dtype=[('a', int), ('b', float), ('c', str)])
isinstance(arr, Array[int, float, str]) # True
isinstance(arr, Array[float, float, str]) # False
isinstance(arr, Array[int, float, str, 2]) # True
Metadata
Release files for nptyping 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nptyping-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for nptyping-0.3.1-py3-none-any.whl |
Release files / nptyping-0.3.1-py3-none-any.whl
| Download URL | nptyping-0.3.1-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87a49b05c4c5d99673e5ea844bca86db5078b777a4c767e987db3b591d0c2358
|
|
BLAKE2b-256 checksum How to use checksums |
1abb2d8603ddde6a63a4e3a3e1106fb2bfecba7f70ccece047baefb919fa412f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for nptyping 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.