Skip to main content

Type hints for Numpy

Project description

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:

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

nptyping also supports instance checks:

import numpy


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nptyping-0.1.0.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nptyping-0.1.0-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file nptyping-0.1.0.tar.gz.

File metadata

  • Download URL: nptyping-0.1.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for nptyping-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b922d938c2c6d3e45e2d13bb2bad26ba43c0437384553d5eaa032f22d24064a9
MD5 60556666c2cab5615808d2b9bc4d89db
BLAKE2b-256 711e99fd126222d9981b69a8727260a21475cb83ff473d33409f282e6b48d747

See more details on using hashes here.

File details

Details for the file nptyping-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nptyping-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for nptyping-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 342c253beacde491cc709322634aebd355d9438675d8b31207bb9d7533b7109a
MD5 1690c6a39dc99623ef2b50101d1433d7
BLAKE2b-256 9bc5005e477e494af52d153ba0a3ab194c50f1bff60200762634c8e25c856f24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page