Metadata-Version: 2.1
Name: nptyping
Version: 0.3.1
Summary: Type hints for Numpy
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: numpy
Requires-Dist: typish

|Python versions| |PyPI version| |Build Status| |Downloads|

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

`nptyping` also supports instance checks:

.. code:: python

   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:

.. code:: python

      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


.. |Python versions| image:: https://img.shields.io/pypi/pyversions/nptyping.svg
   :target: https://img.shields.io/pypi/pyversions/nptyping.svg

.. |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

.. |Downloads| image:: https://img.shields.io/pypi/dm/nptyping.svg
   :target: https://pypistats.org/packages/nptyping


