[cppyy] Set LowLevelView itemsize to sizeof(T) for fixed multidim arrays#21388
[cppyy] Set LowLevelView itemsize to sizeof(T) for fixed multidim arrays#21388aaronj0 wants to merge 3 commits intoroot-project:masterfrom
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 21 files 21 suites 2d 22h 13m 21s ⏱️ For more details on these failures, see this check. Results for commit 6d9f885. ♻️ This comment has been updated with latest results. |
cbf159a to
6d9f885
Compare
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