Skip to main content
|PyPI version| |Build Status|

nptyping
========

Type hints for `Numpy`!

Installation
''''''''''''

::

pip install nptyping

Usage
'''''

Use the `nptyping` type hints like the regular type hints from `typing`:

.. code:: python

from nptyping import Array


def func1(arr: Array[int]): # A numpy.ndarray that contains numbers
...

You can also define the shape of an array:

.. code:: python

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:

.. code:: python

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] # 3 rows and int, float and str on columns 1, 2 and 3 resp.

`nptyping` also supports instance checks:

.. code:: python

import numpy
from nptyping import Array


arr = numpy.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:

.. code:: python

import numpy
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


.. include:: HISTORY.rst


.. |PyPI version| image:: https://badge.fury.io/py/nptyping.svg
:target: https://badge.fury.io/py/nptyping

.. |Build Status| image:: https://api.travis-ci.org/ramonhagenaars/nptyping.svg?branch=master
:target: https://travis-ci.org/ramonhagenaars/nptyping

Metadata

Release files for nptyping 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nptyping 0.2.0
File Size Uploaded Provenance Actions
nptyping-0.2.0.tar.gz 2.7 kB Without provenance Details for nptyping-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nptyping 0.2.0
File Interpreter ABI Platform Actions
nptyping-0.2.0-py3-none-any.whl Python 3 none any Details for nptyping-0.2.0-py3-none-any.whl

Total release size: 5.6 kB

Release files / nptyping-0.2.0.tar.gz

Download URL nptyping-0.2.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8823b7422be989751b9bfdba9155fa3ab06d98db9e57678f0c9a1dae07f452ac
BLAKE2b-256 checksum
How to use checksums
9c7f8003c6713bf3751acad97a87b8bd7b97104cd3be1dbddc5a29d895e3179e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.1

Release files / nptyping-0.2.0-py3-none-any.whl

Download URL nptyping-0.2.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2f8f8b2987ce01731b5ef3a8b9ab2fbc4bf79fde1d57f5287049def379320cc
BLAKE2b-256 checksum
How to use checksums
a50f9b44a1866c7911d03329669d82d2ebb1b8e6dac15803fdb6588549a44193
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.1

Security for nptyping 0.2.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page