numpy-typing


Namenumpy-typing JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryImproved numpy typing anotations
upload_time2024-09-27 12:45:05
maintainerNone
docs_urlNone
authorPirolley Melvyn
requires_pythonNone
licenseNone
keywords python deep learning tensorflow aircraft classification ads-b
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
This package adds cleaner typing to 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 :
```python
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 : The numpy imported there it is not slower than the classical numpy (``import numpy as np``). When calling a numpy function, its code is directly called without any wrapper. Numpy-typing only overload numpy's function annotations.


You can then use new annotation like:
```python
from numpy_typing import np, ax

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, ...]``` without type.

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:
```python
from numpy_typing import np, ax

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](https://github.com/user/repo/blob/branch/other_file.md).













            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "numpy-typing",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, deep learning, tensorflow, aircraft, classification, ADS-B",
    "author": "Pirolley Melvyn",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/78/e6/8507f5e913f12396ec72307377429cf93b068c8e2f930f417fd80a81da0c/numpy_typing-1.0.1.tar.gz",
    "platform": null,
    "description": "\nThis package adds cleaner typing to numpy arrays.  It\nhas been designed for deep learning and data processing tasks which generally\nneed a lot of numpy arrays of large dimensions.\n\n\nTo use the library modify all your import with :\n```python\nfrom numpy_typing import np, ax\n```\n\nThe modified version of numpy imported there contain sumplementary annotations in order to have smart and automatic inferred annotation.\n\n> Remark : The numpy imported there it is not slower than the classical numpy (``import numpy as np``). When calling a numpy function, its code is directly called without any wrapper. Numpy-typing only overload numpy's function annotations.\n\n\nYou can then use new annotation like:\n```python\nfrom numpy_typing import np, ax\n\nfloat32Array3d:np.float32_3d[ax.batch, ax.sample, ax.feature] = np.zeros((3, 3, 3))\nv = float32Array3d[0, 0, 0] # v automatically inferred as float32\n```\nThe library add new array_types annotation:\n- np.float32_*n*d\n- np.float64_*n*d\n- np.int32_*n*d\n- np.int64_*n*d\n- np.int8_*n*d\n- np.bool_*n*d\n- np.str_*n*d\n\nWhere *n* is the number of dimension of the array. The value of *n* is for instance only supported between [1, 4].\n\nMoreover, 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, ...]``` without type.\n\nThen you should specify for each dimension the role of the dimension:\n- ax.batch: The axis select the nth batch\n- ax.sample: The axis select the nth sample of the batch\n- ax.feature: The axis contain features\n- ax.time: The axis represent the time\n- ax.label: the axis contain labels\n- ax.x: The axis represent the x coordinate\n- ax.y: The axis represent the y coordinate\n- ax.z: The axis represent the z coordinate\n- ax.rgb: the axis contain a rgb value [0] for red, [1] for green and [2] for blue\n- ax.rgba: the axis contain a rgba value [0] for red, [1] for green, [2] for blue and [3] for alpha\n\nHere is an example of useful smart annotation:\n```python\nfrom numpy_typing import np, ax\n\na:np.float32_1d[ax.time] = np.zeros((64))\nb:np.float32_1d[ax.time] = np.zeros((64))\nc = np.concatenate([a, b])\n# automatically infer the type of c as np.float32_1d[ax.time]\n```\n\nIf 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](https://github.com/user/repo/blob/branch/other_file.md).\n\n\n\n\n\n\n\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Improved numpy typing anotations",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [
        "python",
        " deep learning",
        " tensorflow",
        " aircraft",
        " classification",
        " ads-b"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "78e68507f5e913f12396ec72307377429cf93b068c8e2f930f417fd80a81da0c",
                "md5": "252aae6017a8dbfc9ed246daf7a7dc35",
                "sha256": "3095ea61866b157f7412aad774ba4ef5a253a9e394c723f032ccc64c313bf187"
            },
            "downloads": -1,
            "filename": "numpy_typing-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "252aae6017a8dbfc9ed246daf7a7dc35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3491,
            "upload_time": "2024-09-27T12:45:05",
            "upload_time_iso_8601": "2024-09-27T12:45:05.441202Z",
            "url": "https://files.pythonhosted.org/packages/78/e6/8507f5e913f12396ec72307377429cf93b068c8e2f930f417fd80a81da0c/numpy_typing-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 12:45:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "numpy-typing"
}
        
Elapsed time: 0.60056s