Skip to main content

Type stubs for Python machine learning libraries

Project description

Python type stubs for numpy, pandas and matplotlib

This is a PEP-561-compliant stub-only package which provides type information for matplotlib, numpy and pandas. The mypy type checker can recognize the types in these packages by installing this package:

pip install data-science-types

There is also minor support for Tensorflow and Tensorflow Probability.

Examples

These are the kinds of things that can be checked:

Array creation

import numpy as np

arr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3])  # OK
arr2: np.ndarray[np.int32] = np.array([3, 7, 39, -3])  # Type error
arr3: np.ndarray[np.int32] = np.array([3, 7, 39, -3], dtype=np.int32)  # OK
arr4: np.ndarray[float] = np.array([3, 7, 39, -3], dtype=float)  # Type error: the type of ndarray can not be just "float"
arr5: np.ndarray[np.float64] = np.array([3, 7, 39, -3], dtype=float)  # OK

Operations

import numpy as np

arr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3])
arr2: np.ndarray[np.int64] = np.array([4, 12, 9, -1])

result1: np.ndarray[np.int64] = np.divide(arr1, arr2)  # Type error
result2: np.ndarray[np.float64] = np.divide(arr1, arr2)  # OK

compare: np.ndarray[np.bool_] = (arr1 == arr2)

Philosophy

The goal is not to recreate the class hierarchy exactly. The goal is to have useful checks on our code. Often the actual API in the libraries is more permissive than the type signatures in our stubs; but this is (usually) a feature and not a bug.

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

data-science-types-0.1.6.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

data_science_types-0.1.6-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file data-science-types-0.1.6.tar.gz.

File metadata

  • Download URL: data-science-types-0.1.6.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for data-science-types-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4c1e23f746ce12188db109fb0be76055cb51e673c30bab8056e12eae78824e30
MD5 41a6c19f526f48dab5322cc936882cc4
BLAKE2b-256 6bd96b4076dd14fd54dec1e65d245c7184f025ff41fa3c3d7533d9d5e1e9a2d2

See more details on using hashes here.

File details

Details for the file data_science_types-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: data_science_types-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for data_science_types-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 afa800a063a4f5a8cd9b3c081ab0aaaebbb362967112aa417c46f31a024957b9
MD5 86e8c2a9468a2fbe5db0471724306c1b
BLAKE2b-256 7713d5800461570dda321776af3cec0ca5fb5d0e7fdf83c560cf3710e491e718

See more details on using hashes here.

Supported by

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