Skip to content

Conversation

@antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Jan 26, 2026

The PR aligns with NumPy 2.4 change and adds support for tuple of integers passed with axis argument in dpnp.trim_zeros

  • 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?

@antonwolfy antonwolfy added this to the 0.20.0 release milestone Jan 26, 2026
@antonwolfy antonwolfy self-assigned this Jan 26, 2026
@github-actions
Copy link
Contributor

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

@coveralls
Copy link
Collaborator

coveralls commented Jan 26, 2026

Coverage Status

coverage: 81.103% (-0.001%) from 81.104%
when pulling 1775a82 on support-axis-sequence-in-trim_zeros
into 869ccb8 on master.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

Array API standard conformance tests for dpnp=0.20.0dev2=py313h509198e_15 ran successfully.
Passed: 1227
Failed: 0
Skipped: 9

@antonwolfy antonwolfy marked this pull request as ready for review January 27, 2026 10:48
nd = filt.ndim
if axis is not None:
axis = normalize_axis_index(axis, nd)
if axis is None:
Copy link
Contributor

@vlad-perevezentsev vlad-perevezentsev Jan 27, 2026

Choose a reason for hiding this comment

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

Incorrect shape for empty input with Numpy 2.4

a = numpy.empty((0,3))
a_dp = dpnp.empty((0,3))

numpy.trim_zeros(a,axis=None).shape
# (0, 0)

dpnp.trim_zeros(a_dp, axis=None).shape
# (0, 3)

Copy link
Contributor Author

@antonwolfy antonwolfy Jan 27, 2026

Choose a reason for hiding this comment

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

It seems more as a bug in NumPy implementation which existed before 2.4 release as well.
An empty array does not contain any zero elements, so there is nothing to trim. IMHO it is correct to return the input array unchanged then.

Copy link
Contributor

Choose a reason for hiding this comment

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

@antonwolfy could you add a test that shows different behavior with NumPy and a comment for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test to cover dpnp behavior with 0-sized input array.
I don't see a reason to check the NumPy behavior, if it's faulty.

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