Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This release is compatible with NumPy 2.4.5.
* Replaced `.pxi` includes in `dpnp.tensor` with modular `.pxd`/`.pyx` Cython imports [#2913](https://github.com/IntelPython/dpnp/pull/2913)
* Reimplemented `dpnp.eye` and `dpnp.tensor.eye` with a branchless kernel [gh-2937](https://github.com/IntelPython/dpnp/pull/2937)
* Cleaned up Python bindings for indexing functions, renaming `usm_ndarray_take` and `usm_ndarray_put` to `py_take` and `py_put` and refactoring validation [gh-2935](https://github.com/IntelPython/dpnp/pull/2935)
* Changed `dpnp.broadcast_arrays` and `dpnp.tensor.broadcast_arrays` to return a tuple instead of a list, aligning with NumPy 2.x behavior and 2025.12 version of the Python array API standard [#2944](https://github.com/IntelPython/dpnp/pull/2944)

### Deprecated

Expand Down
12 changes: 6 additions & 6 deletions dpnp/dpnp_iface_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,8 @@ def broadcast_arrays(*args, subok=False):

Returns
-------
out : list of dpnp.ndarray
A list of arrays which are views on the original arrays from `args`.
out : tuple of dpnp.ndarray
A tuple of arrays which are views on the original arrays from `args`.

Limitations
-----------
Expand All @@ -1078,20 +1078,20 @@ def broadcast_arrays(*args, subok=False):
>>> x = np.array([[1, 2, 3]])
>>> y = np.array([[4], [5]])
>>> np.broadcast_arrays(x, y)
[array([[1, 2, 3],
(array([[1, 2, 3],
[1, 2, 3]]), array([[4, 4, 4],
[5, 5, 5]])]
[5, 5, 5]]))

"""

if subok is not False:
raise NotImplementedError(f"subok={subok} is currently not supported")

if len(args) == 0:
return []
return ()

usm_arrays = dpt.broadcast_arrays(*[dpnp.get_usm_ndarray(a) for a in args])
return [dpnp_array._create_from_usm_ndarray(a) for a in usm_arrays]
return tuple(dpnp_array._create_from_usm_ndarray(a) for a in usm_arrays)


def broadcast_shapes(*args):
Expand Down
6 changes: 3 additions & 3 deletions dpnp/tensor/_manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def broadcast_arrays(*args):
broadcasted.

Returns:
List[usm_ndarray]:
A list of broadcasted arrays. Each array
tuple[usm_ndarray, ...]:
A tuple of broadcasted arrays. Each array
must have the same shape. Each array must have the same `dtype`,
`device` and `usm_type` attributes as its corresponding input
array.
Expand All @@ -245,7 +245,7 @@ def broadcast_arrays(*args):
if all(X.shape == shape for X in args):
return args

return [broadcast_to(X, shape) for X in args]
return tuple(broadcast_to(X, shape) for X in args)


def broadcast_to(X, /, shape):
Expand Down
2 changes: 1 addition & 1 deletion dpnp/tests/test_arraymanipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def test_incompatible_shapes_raise_valueerror(self, shapes):
self.assert_broadcast_arrays_raise(input_shapes[::-1])

def test_broadcast_arrays_empty_input(self):
assert dpnp.broadcast_arrays() == []
assert dpnp.broadcast_arrays() == ()

def test_subok_error(self):
x = dpnp.ones(4)
Expand Down
Loading