[cppyy] Set LowLevelView itemsize to sizeof(T) for fixed multidim arrays#21388
Conversation
For fixed contiguous C arrays (e.g. float a[2][2]), the ndim > 1 path in CreateLowLevelViewT was unconditionally setting view.itemsize to sizeof(void*), which is correct for pointer-to-pointer arrays but does not work for fixed arrays. Fixes root-project#21378
vepadulano
left a comment
There was a problem hiding this comment.
This is great! Could you also add a test?
neat, this actually revealed a bug in a test Back then, I didn't realise why I had to read the buffer as 1D and reshape the resulting Py_buffer but now it all makes sense... With this patch, |
…numpy This was a (terrible) workaround to the fact that resulting views of multidim arrays did not convey the right itemsize based on the underlying type. Now that root-project#21378 is fixed, the workaround breaks and we can just use `np.array(arr, dtype)` which is a lot better and Pythonic for users.
Test Results 22 files 22 suites 3d 2h 31m 27s ⏱️ For more details on these failures, see this check. Results for commit 22b34ec. ♻️ This comment has been updated with latest results. |
cbf159a to
6d9f885
Compare
6d9f885 to
22b34ec
Compare
|
ruff formatting has been addressed |
Yep, that's expected. You can choose to either merge this PR as is, or take the chance to ruff format and ruff check the entire file, but then those changes would go in a separate commit. Up to you. |
As we want to minimize the diff with upstream, we should keep the cppyy/test files the same. Merging, as test failures on mac-beta ( |
|
/backport to 6.38 |
For fixed contiguous C arrays (e.g. float a[2][2]), the ndim > 1 path in CreateLowLevelViewT was unconditionally setting view.itemsize to sizeof(void*), which is correct for pointer-to-pointer arrays but does not work for fixed arrays. Fixes #21378