Skip to content

Commit 466b4f7

Browse files
committed
✨ start ArrayNamespace protocol
Signed-off-by: nstarman <[email protected]>
1 parent c65c5d5 commit 466b4f7

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

src/array_api_typing/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Static typing support for the array API standard."""
22

3-
__all__ = (
3+
__all__ = ( # noqa: RUF022
4+
# ==================
5+
# Array
46
"Array",
57
"HasArrayNamespace",
68
"HasDType",
@@ -9,6 +11,10 @@
911
"HasShape",
1012
"HasSize",
1113
"HasTranspose",
14+
# ==================
15+
# Namespace
16+
"ArrayNamespace",
17+
# ==================
1218
"__version__",
1319
"__version_tuple__",
1420
)
@@ -23,4 +29,5 @@
2329
HasSize,
2430
HasTranspose,
2531
)
32+
from ._namespace import ArrayNamespace
2633
from ._version import version as __version__, version_tuple as __version_tuple__

src/array_api_typing/_array_docstrings.json

Whitespace-only changes.

src/array_api_typing/_array_docstrings.toml

Whitespace-only changes.

src/array_api_typing/_namespace.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from typing import Protocol
2+
3+
__all__ = ("ArrayNamespace",)
4+
5+
# ===================================================================
6+
# Creation Functions
7+
# TODO: arange, asarray, empty, empty_like, eye, from_dlpack, full, full_like,
8+
# linspace, meshgrid, ones, ones_like, tril, triu, zeros, zeros_like
9+
10+
# ===================================================================
11+
# Data Type Functions
12+
# TODO: astype, broadcast_arrays, broadcast_to, can_cast, finfo, iinfo,
13+
# result_type
14+
15+
# ===================================================================
16+
# Element-wise Functions
17+
# TODO: abs, acos, acosh, add, asin, asinh, atan, atan2, atanh, bitwise_and,
18+
# bitwise_invert, bitwise_left_shift, bitwise_or, bitwise_right_shift,
19+
# bitwise_xor, ceil, cos, cosh, divide, equal, exp, exp2, expm1, floor,
20+
# floor_divide, greater, greater_equal, isfinite, isinf, isnan, less,
21+
# less_equal, log, log1p, log2, log10, logical_and, logical_not, logical_or,
22+
# logical_xor, multiply, negative, not_equal, positive, pow, remainder, round,
23+
# sign, sin, sinh, square, sqrt, subtract, tan, tanh, trunc
24+
25+
26+
# ===================================================================
27+
# Linear Algebra Functions
28+
# TODO: matmul, matrix_transpose, tensordot, vecdot
29+
30+
# ===================================================================
31+
# Manipulation Functions
32+
# TODO: concat, expand_dims, flip, permute_dims, reshape, roll, squeeze, stack
33+
34+
# ===================================================================
35+
# Searching Functions
36+
# TODO: argmax, argmin, nonzero, where
37+
38+
# ===================================================================
39+
# Set Functions
40+
# TODO: unique_all, unique_counts, unique_inverse, unique_values
41+
42+
# ===================================================================
43+
# Sorting Functions
44+
# TODO: argsort, sort
45+
46+
# ===================================================================
47+
# Statistical Functions
48+
# TODO: max, mean, min, prod, std, sum, var
49+
50+
# ===================================================================
51+
# Utility Functions
52+
# TODO: all, any
53+
54+
# ===================================================================
55+
# Full Namespace
56+
57+
58+
class ArrayNamespace(Protocol):
59+
"""Protocol for an Array API-compatible namespace."""

0 commit comments

Comments
 (0)