Skip to main content

typed-numpy

Ruff

Typed NumPy with static shape typing and runtime shape validation.

[!WARNING] Experimental & WIP. See USAGE.md for more details.

Installation

Install uv (optional, recommended)

Install uv, if not already. Check here for installation instructions.

It is recommended to use uv, as it will automatically install the dependencies in a virtual environment. If you don't want to use uv, skip to the next step.

TL;DR: Just run

curl -LsSf https://astral.sh/uv/install.sh | sh
Install the package

The dependencies are listed in the pyproject.toml file. At present, the only required dependency is numpy.

Install the package from the PyPI release:

# Using uv
uv add typed-numpy

# Or with pip
pip3 install typed-numpy

To install from the latest commit:

uv add git+https://github.com/AshrithSagar/typed-numpy.git@main

Usage

from typing import TypeVar

from typed_numpy._typed.ndarray import TypedNDArray

# Shape variables are just regular TypeVar's
N = TypeVar("N", bound=int, default=int)
M = TypeVar("M", bound=int, default=int)

# Create aliases such as these, or use TypedNDArray directly
Vector = TypedNDArray[tuple[N]]
Matrix = TypedNDArray[tuple[M, N]]

v1 = Vector([1, 2, 3])  # Passes
v2 = Vector([4, 5, 6, 7])  # Also passes

v3 = TypedNDArray[tuple[int]]([[8, 9]])
# Fails, since expected 1D array but passed in a 2D array

See USAGE.md for more details.

License

This project falls under the MIT License.

Metadata

Release files for typed-numpy 0.2.2

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

Source distribution (sdist)

Source distribution for typed-numpy 0.2.2
File Size Uploaded
typed_numpy-0.2.2.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typed-numpy 0.2.2
File Interpreter ABI Platform
typed_numpy-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / typed_numpy-0.2.2.tar.gz

Download URL typed_numpy-0.2.2.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f1e565427bf0e5946833496a2af47747cfa32245727e106142ad09989abbe720
BLAKE2b-256 checksum
How to use checksums
d33bf01f57f178cd37503f3dc463b76e030ffe378740cdabc202c977c3f7910b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / typed_numpy-0.2.2-py3-none-any.whl

Download URL typed_numpy-0.2.2-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5cbf42ab286731292add821181fa1201cb2f6ac6a98c630b6bae2bcab88ada9
BLAKE2b-256 checksum
How to use checksums
30fe416ed83b4fd1a65559d390a3edb88dc50224bf0352dd6d233364e424ad3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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