Skip to content

Add ndarray subclassing support via ndarray.view() method#2815

Merged
antonwolfy merged 6 commits intomasterfrom
resolve-gh-2764
Mar 20, 2026
Merged

Add ndarray subclassing support via ndarray.view() method#2815
antonwolfy merged 6 commits intomasterfrom
resolve-gh-2764

Conversation

@antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Mar 11, 2026

The PR adds ndarray subclassing support via ndarray.view() method.

It implements the type parameter in dpnp.ndarray.view() to enable custom subclasses, matching NumPy/CuPy behavior. Also includes proper __array_finalize__ hook invocation for metadata propagation.

The implementation is done through _view_impl() helper using 'array_class' parameter to avoid shadowing builtin 'type'.
The tests scope is extended with new 7 tests for verifying subclassing support and enabling TestSubclassArrayView class from third party tests.

This PR closes #2764.

  • 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 Mar 11, 2026
@antonwolfy antonwolfy self-assigned this Mar 11, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Array API standard conformance tests for dpnp=0.20.0dev4=py313h509198e_19 ran successfully.
Passed: 1354
Failed: 3
Skipped: 16

@coveralls
Copy link
Collaborator

coveralls commented Mar 11, 2026

Coverage Status

coverage: 81.977% (+0.02%) from 81.962%
when pulling 8fe24a3 on resolve-gh-2764
into c8c0f88 on master.

@antonwolfy antonwolfy marked this pull request as ready for review March 11, 2026 19:20
Copy link
Contributor

@vlad-perevezentsev vlad-perevezentsev left a comment

Choose a reason for hiding this comment

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

No comments from my side
LGTM
Thank you @antonwolfy

@antonwolfy antonwolfy merged commit d74afaf into master Mar 20, 2026
68 of 77 checks passed
@antonwolfy antonwolfy deleted the resolve-gh-2764 branch March 20, 2026 14:34
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.

Support for ndarray subclassing via view(type=...)

3 participants