Skip to content

Latest commit

 

History

History
109 lines (78 loc) · 3.7 KB

File metadata and controls

109 lines (78 loc) · 3.7 KB

Python array API standard typing

CI Status Documentation Status Test coverage percentage

uv Ruff pre-commit

PyPI Version Supported Python versions License


Documentation: https://array-api.readthedocs.io

Source Code: https://github.com/34j/array-api


Typing for array API and array-api-compat

Installation

Install this via pip (or your favourite package manager):

pip install array-api

Usage

Type stubs

Provices type stubs for array-api-compat.

import array_api_compat

xp = array_api_compat.array_namespace(x)

Array Type

from array_api._2024_12 import Array


def my_function[TArray: Array](x: TArray) -> TArray:
    return x + 1

Namespace Type

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)

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Copier

This package was created with Copier and the browniebroke/pypackage-template project template.