Fix dpnp.linspace returning NaN for equal infinite endpoints - #3043
Open
antonwolfy wants to merge 1 commit into
Open
Fix dpnp.linspace returning NaN for equal infinite endpoints#3043antonwolfy wants to merge 1 commit into
dpnp.linspace returning NaN for equal infinite endpoints#3043antonwolfy wants to merge 1 commit into
Conversation
Backport numpy#31620: equal endpoints must produce a zero step instead of evaluating inf - inf (or inf * 0), which yields NaN. - dpnp_linspace: fill directly for equal scalar endpoints and zero the delta where array endpoints coincide - LinearSequenceAffineFunctor: short-circuit to a constant sequence when start == stop, fixing dpnp.tensor.linspace at its root
Contributor
|
Array API standard conformance tests for dpnp=0.21.0dev6=py314ha0e2e8e_18 ran successfully. |
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3043/index.html |
Collaborator
antonwolfy
marked this pull request as ready for review
August 26, 2026 19:48
antonwolfy
requested review from
ndgrigorian and
vlad-perevezentsev
as code owners
August 26, 2026 19:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dpnp.linspacereturnedNaNinstead of the endpoint value whenstartandstopare equal and infinite — e.g.dpnp.linspace(inf, inf, 4)gave[nan inf inf nan].The bug had two independent sources:
dpnp_linspacecomputeddelta = stop - start, soinf - inf = NaNpropagated through the whole result.dpnp.tensor.linspace, whose affine kernelLinearSequenceAffineFunctorevaluatesstart * w + stop * wc; at the endpoints one weight is0, andinf * 0 = NaN.The PR proposes to fix all the places.
Note, the tests compare against NumPy on versions that include the fix (NumPy >= 2.6.0) and fall back to explicit expected values on older NumPy.