Skip to content

Update broadcast_arrays to return a tuple instead of a list #2944

Open
vlad-perevezentsev wants to merge 4 commits into
masterfrom
return_tuple_broadcast_arrays
Open

Update broadcast_arrays to return a tuple instead of a list #2944
vlad-perevezentsev wants to merge 4 commits into
masterfrom
return_tuple_broadcast_arrays

Conversation

@vlad-perevezentsev

@vlad-perevezentsev vlad-perevezentsev commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR updates dpnp.broadcast_arrays() and dpnp.tensor.broadcast_arrays() to return a tuple instead of a list aligning their behavior with the Python Array API 2025.12 and NumPy

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2944/index.html

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.251% (+0.003%) from 78.248% — return_tuple_broadcast_arrays into master

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_70 ran successfully.
Passed: 1355
Failed: 5
Skipped: 16


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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we don't have an explicit type assertion in any tensor or dpnp tests, excluding use case with empty input.

@@ -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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed to update dpnp/tests/third_party/cupy/manipulation_tests/test_dims.py with the latest changed (including new test added there for that use case)

Comment thread CHANGELOG.md
* 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by NumPy 2.x? Is it known where it will be done? NumPy 2.5? Then should explicitly state that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants