This package adds cleaner typing for numpy arrays. It has been designed for deep learning and data processing tasks which generally need a lot of numpy arrays of large dimensions.
To use the library modify all your import with :
from numpy_typing import np, ax
The modified version of numpy imported there contain sumplementary annotations in order to have smart and automatic inferred annotation.
Remark : This import load the real Numpy library. As Numpy-Typing do not use wrapper, every Numpy functions are directly called without intermediate code. Hence Numpy-Typing is as fast as Numpy.
You can then use new annotation like:
float32Array3d:np.float32_3d[ax.batch, ax.sample, ax.feature] = np.zeros((3, 3, 3))
v = float32Array3d[0, 0, 0] # v automatically inferred as float32
The library add new array_types annotation:
- np.float32_(n)d
- np.float64_(n)d
- np.int32_(n)d
- np.int64_(n)d
- np.int8_(n)d
- np.bool_(n)d
- np.str_(n)d
Where n is the number of dimension of the array. The value of n is for instance only supported between [1, 4].
Moreover, as the library dosen't support yet all the numpy types, you can also use the generic type
np.array_(1-4)d[dtype, axis1, ...]
Then you should specify for each dimension the role of the dimension:
- ax.batch: The axis select the nth batch
- ax.sample: The axis select the nth sample of the batch
- ax.feature: The axis contain features
- ax.time: The axis represent the time
- ax.label: the axis contain labels
- ax.x: The axis represent the x coordinate
- ax.y: The axis represent the y coordinate
- ax.z: The axis represent the z coordinate
- ax.rgb: the axis contain a rgb value [0] for red, [1] for green and [2] for blue
- ax.rgba: the axis contain a rgba value [0] for red, [1] for green, [2] for blue and [3] for alpha
Here is an example of useful smart annotation:
a:np.float32_1d[ax.time] = np.zeros((64))
b:np.float32_1d[ax.time] = np.zeros((64))
c = np.concatenate([a, b])
# automatically infer the type of c as np.float32_1d[ax.time]
If you want the library to support more types, more numpy functions or if you have any suggestion, feel free to open an issue on our github.
Metadata
Release files for numpy-typing 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| numpy_typing-1.1.1.tar.gz | 6.9 kB | Without provenance | Details |
Release files / numpy_typing-1.1.1.tar.gz
| Download URL | numpy_typing-1.1.1.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
023005afafbc72d84b450d23a2f110cfca255bddd1ef55aa8ef87207a9dbf83c
|
|
BLAKE2b-256 checksum How to use checksums |
b0710e00b8ea4d0a6b6ec89ee16b68225fbe68e390e43e5e49c4532d9b7e8165
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Security for numpy-typing 1.1.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.