Skip to content

Allow same-kind casting of the result into out in dpnp.take and dpnp.compress#2959

Open
antonwolfy wants to merge 4 commits into
masterfrom
allow-same-kind-castiing-in-take
Open

Allow same-kind casting of the result into out in dpnp.take and dpnp.compress#2959
antonwolfy wants to merge 4 commits into
masterfrom
allow-same-kind-castiing-in-take

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Previously dpnp.take and dpnp.compress raised a TypeError whenever the provided out array had a dtype different from the input array (strictly followed Python array API):

out (array) – an array having the same data type as x.

This PR relaxes that check to allow casting the result into an out array of a different but same-kind dtype (e.g. int32 -> int64, int32 -> float32), aligning the behavior closer to dpnp documentation clamming:

It should be of the appropriate shape and dtype.

and aligning with recent changes done in NumPy 2.5.

  • 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.21.0 release milestone Jun 19, 2026
@antonwolfy antonwolfy self-assigned this Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.084% (-0.004%) from 78.088% — allow-same-kind-castiing-in-take into master

@github-actions

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev1=py313h509198e_17 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

@antonwolfy antonwolfy marked this pull request as ready for review June 19, 2026 15:54
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.

2 participants