Python strong typing suite, along with Typed NumPy: Static shape typing and runtime shape validation.
Warning
Experimental & WIP. See USAGE.md for more details.
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 | shInstall 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 typingkit
# Or with pip
pip3 install typingkitTo install from the latest commit:
uv add git+https://github.com/AshrithSagar/typingkit.git@mainfrom typing import TypeVar
from typingkit._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 arraySee USAGE.md for more details.
This project falls under the MIT License.