Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions array_api_strict/_creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def linspace(
)


def meshgrid(*arrays: Array, indexing: Literal["xy", "ij"] = "xy") -> list[Array]:
def meshgrid(*arrays: Array, indexing: Literal["xy", "ij"] = "xy") -> tuple[Array, ...]:
"""
Array API compatible wrapper for :py:func:`np.meshgrid <numpy.meshgrid>`.

Expand All @@ -327,10 +327,12 @@ def meshgrid(*arrays: Array, indexing: Literal["xy", "ij"] = "xy") -> list[Array
else:
device = None

return [
typ = list if get_array_api_strict_flags()['api_version'] < '2025.12' else tuple

return typ(
Array._new(array, device=device)
for array in np.meshgrid(*[a._array for a in arrays], indexing=indexing)
]
)


def ones(
Expand Down
8 changes: 5 additions & 3 deletions array_api_strict/_data_type_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ def astype(
return Array._new(x._array.astype(dtype=dtype._np_dtype, copy=copy), device=device)


def broadcast_arrays(*arrays: Array) -> list[Array]:
def broadcast_arrays(*arrays: Array) -> tuple[Array, ...]:
"""
Array API compatible wrapper for :py:func:`np.broadcast_arrays <numpy.broadcast_arrays>`.

See its docstring for more information.
"""
from ._array_object import Array

return [
typ = list if get_array_api_strict_flags()['api_version'] < '2025.12' else tuple

return typ(
Array._new(array, device=arrays[0].device) for array in np.broadcast_arrays(*[a._array for a in arrays])
]
)


def broadcast_to(x: Array, /, shape: tuple[int, ...]) -> Array:
Expand Down
4 changes: 2 additions & 2 deletions array_api_strict/_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ def dtypes(
raise ValueError(f"unsupported kind: {kind!r}")

@requires_api_version('2023.12')
def devices(self) -> list[Device]:
return list(ALL_DEVICES)
def devices(self) -> tuple[Device]:
return tuple(ALL_DEVICES)
Loading