[CPyCppyy] Drop __array__ from std::vector pythonizations#18208
Merged
Conversation
Test Results 17 files 17 suites 4d 3h 24m 56s ⏱️ For more details on these failures, see this check. Results for commit 55e8ca6. ♻️ This comment has been updated with latest results. |
guitargeek
reviewed
Apr 1, 2025
The addition of the __array__ utility to std::vector Python proxies causes a bug where the resulting array is a single dimension, causing loss of data when converting to numpy arrays, for >1dim vectors. The recursive nature of this function, passes each subarray (pydata) to the next call and only the final buffer is cast to a lowlevel view and resized (in VectorData), resulting in only the first 1D array to be returned. See root-project#17729 Since this C++ pythonization was added with the upgrade in 6.32, and is only defined and used recursively, the safe option is to disable this function and no longer add it. It is temporarily removed to prevent errors due to -Wunused-function
__array__ from std::vector pythonizations in CPyCppyy__array__ from std::vector pythonizations
1 task
guitargeek
approved these changes
Apr 2, 2025
Contributor
guitargeek
left a comment
There was a problem hiding this comment.
Great, thank you very much for the investigation and finding just the right fix!
I'll also backport it to the 6.34 branch, so if there is a patch release of 6.34 before the upcoming 6.36, our users will also benefit from this fix.
1 task
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.
The addition of the
__array__utility to std::vector Python proxies causes a bug where the resulting array is a single dimension, causing loss of data when converting to numpy arrays, for >1dim vectors. The recursive nature of thisfunction
VectorArray, passes each subarray (pydata) to the next call and only the final buffer is cast to a lowlevel view and resized (in VectorData), resulting in only the first 1D array to be returned.Since this C++ pythonization was added with the upgrade in 6.32, and is only defined and used recursively, the safe option is to disable this function and no longer add it. It is temporarily removed to prevent errors due to
-Wunused-functionFixes: #17729