-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Spurious TypeError
exception upon calling asarray
on empty array buffer
#26366
Comments
To help understand why this is happening, ultimately the error is being raised by this C API call:
And the error has this accompanying C traceback (starting from the
No idea if there are other issues, but maybe we just need to have a check for empty shape here: numpy/numpy/_core/src/multiarray/ctors.c Lines 2386 to 2397 in b296087
And not just assume that the array is a scalar at that point. |
Just to note, I think this is a duplicat of gh-26037. There is a strong assumption NULL data means scalar and I am not even sure that makes sense, that whole path seemed very shady when I lookeed it then. |
Describe the issue:
I create an object exhibiting the array interface for a size-zero array with a NULL pointer as storage. Numpy mumbles something seemingly spurious about
float
when trying to callasarray
on that object.Reproduce the code example:
Error message:
Python and NumPy Versions:
1.26.4
3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0]
Runtime Environment:
Context for the issue:
I maintain PyOpenCL. The issue arose in the handling of empty shared-virtual-memory ("SVM") allocations, which PyOpenCL needs to support. PyOpenCL tightly integrates with numpy, and particularly SVM allocations (i.e. memory that is accessible both from the host and the compute device/GPU) are exposed as numpy arrays. Numpy seems to support empty arrays just fine, just creating them through the array interface appears to lead to this, seemingly, spurious error.
The text was updated successfully, but these errors were encountered: