Skip to content

Files

Latest commit

f32f717 · Jun 16, 2025

History

History
112 lines (80 loc) · 3.92 KB

README.md

File metadata and controls

112 lines (80 loc) · 3.92 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/types-array-api


Typing for array API and array-api-compat

Installation

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

pip install types-array-api

Usage

Type stubs

Provices type stubs for array-api-compat.

import array_api_compat

xp = array_api_compat.array_namespace(x)

Screenshot 1 Screenshot 2

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.