Repository navigation
Deprecate scalar upcast in dpnp.append with axis=None - #3125
Open
antonwolfy wants to merge 1 commit into
Open
antonwolfy wants to merge 1 commit into
antonwolfy wants to merge 1 commit into
Conversation
`dpnp.append` converts a Python numeric scalar in `values` to an array before choosing the result dtype, so it can upcast `arr` (e.g. `int8` array and `1` give `int64`). Emit a `FutureWarning` when Python scalar promotion rules would give a different dtype, aligning with NumPy 2.6. The result is unchanged. Python bool, NumPy scalars and lists do not warn.
antonwolfy
requested review from
ndgrigorian and
vlad-perevezentsev
as code owners
October 25, 2026 12:37
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3125/index.html |
Collaborator
ndgrigorian
approved these changes
Oct 26, 2026
This branch has not been deployed
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.appendwithaxis=Noneconverts a Python numeric scalar invaluesto an array before choosing the result dtype, so the scalar can upcastarr. NumPy 2.6 deprecates this behavior: a future release will use the Python scalar promotion rules instead, asconcatenatedoes. This PR mirrors that deprecation.The result is unchanged, but the call now emits:
The warning is emitted only when the dtype will actually change, i.e. when
dpnp.result_type(arr, values)differs from the current result dtype. As in NumPy, only exact Pythonint,floatandcomplexscalars are affected; Pythonbool, NumPy scalars, lists and arrays don't warn. Values out of range for the future dtype (e.g.300with auint8array) will raiseOverflowErroronce the change lands.On devices without fp64 support, a Python
floatorcomplexscalar already converts to a single-precision array, so e.g. afloat32array keeps its dtype and no warning is emitted there.