Skip to content

Fix dpnp.mgrid/dpnp.ogrid inconsistency for complex steps with non-integer magnitude#2971

Open
antonwolfy wants to merge 4 commits into
masterfrom
fix-issue-in-nd_grid
Open

Fix dpnp.mgrid/dpnp.ogrid inconsistency for complex steps with non-integer magnitude#2971
antonwolfy wants to merge 4 commits into
masterfrom
fix-issue-in-nd_grid

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

For a complex step, the integer part of its magnitude is the number of points to generate (start and stop inclusive). The single-slice and tuple-of-slices code paths disagreed when the step magnitude was not an integer (e.g. 2.5j):

  • the tuple path used int(abs(step)) - 1 as the divisor (correct), while
  • the single-slice path used the float magnitude abs(step) - 1 as the divisor.

As a result dpnp.mgrid[0:10:2.5j] and dpnp.mgrid[0:10:2.5j,] produced different arrays, and the single-slice form disagreed with NumPy.

>>> dpnp.mgrid[0:10:2.5j]      # before: [0. , 6.667]   after: [ 0., 10.]
>>> dpnp.mgrid[0:10:2.5j,][0]  # always: [ 0., 10.]     (matches 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?

@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jun 24, 2026
@antonwolfy antonwolfy self-assigned this Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.066% (-0.003%) from 78.069% — fix-issue-in-nd_grid into master

@github-actions

Copy link
Copy Markdown
Contributor

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

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