Skip to content

Commit b2e89ab

Browse files
committed
refactor: loosen language around propagation of dimensions of unknown size
1 parent 56064e7 commit b2e89ab

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/array_api_stubs/_draft/manipulation_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ def broadcast_arrays(*arrays: array) -> Tuple[array, ...]:
3636
"""
3737

3838

39-
def broadcast_shapes(*shapes: Tuple[int, ...]) -> Tuple[int, ...]:
39+
def broadcast_shapes(*shapes: Tuple[int | None, ...]) -> Tuple[int | None, ...]:
4040
"""
4141
Broadcasts one or more shapes against one another.
4242
4343
Parameters
4444
----------
45-
shapes: Tuple[int, ...]
45+
shapes: Tuple[int | None, ...]
4646
an arbitrary number of to-be broadcasted shapes.
4747
4848
Returns
4949
-------
50-
out: Tuple[int, ...]
50+
out: Tuple[int | None, ...]
5151
a single broadcasted shape obtained by applying broadcasting rules (see :ref:`broadcasting`) to each of the input shapes against one another.
5252
5353
Raises
@@ -59,7 +59,7 @@ def broadcast_shapes(*shapes: Tuple[int, ...]) -> Tuple[int, ...]:
5959
-----
6060
6161
- If not provided one or more arguments, the function **must** return an empty tuple.
62-
- An array-conforming library **may** accept a non-integer value (e.g., ``None``) for one or more dimensions. This is common for array libraries which build computation graphs (e.g., ndonnx and Dask) and which need to provide a mechanism for indicating dimensions of unknown size. Array-conforming libraries which accept non-integer values for dimensions of unknown size **must** propagate such values (e.g., if a shape contains a dimension size of ``None``, the returned broadcasted shape **must** also have a corresponding dimension having a size equal to ``None``); otherwise, an array-conforming library **must** raise a ``ValueError``.
62+
- Array-conforming libraries which build computation graphs (e.g., ndonnx and Dask) and which need to provide a mechanism for indicating dimensions of unknown size **may** accept non-integer values (e.g., ``None``). For these libraries, dimensions of unknown size **must** be propagated to the returned shape.
6363
"""
6464

6565

0 commit comments

Comments
 (0)