Documentation: https://array-api.readthedocs.io
Source Code: https://github.com/34j/array-api
Typing for array API and array-api-compat
Install this via pip (or your favourite package manager):
pip install array-api
Provices type stubs for array-api-compat
.
import array_api_compat
xp = array_api_compat.array_namespace(x)
from array_api._2024_12 import Array
def my_function[TArray: Array](x: TArray) -> TArray:
return x + 1
You can test if an object matches the Protocol by:
import array_api_strict
from array_api._2024_12 import ArrayNamespace, ArrayNamespaceFull
assert isinstance(array_api_strict, ArrayNamespace)
# Full version contains fft and linalg
# fft and linalg are not included by default in array_api_strict
assert not isinstance(array_api_strict, ArrayNamespaceFull)
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
This package was created with Copier and the browniebroke/pypackage-template project template.