-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: numpy.isscalar thinks that memoryview is always a scalar #8538
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
Comments
Aaah, a bit weird and probably wrong. It would seem (from the code) that the thought it that a buffer/memoryview is something like a void python object (which to some degree may even be true, though I have my doubts). Just to note though, its all in |
Worse yet, gh-9898 means that this only happens on python 3 |
Are there any plans to fix this soon? |
From the docs of isscalar
I think that returning false on 0d |
# 0-D and 1-D arrays
>>> x0 = np.array(0)
>>> x1 = np.array([])
>>> np.isscalar(x0)
False
>>> np.isscalar(x1)
False
# A NumPy scalar
>>> dt0 = np.float64(0)
>>> np.isscalar(dt0)
True
# When going through `memoryview` for all those things
>>> np.isscalar(memoryview(dt0))
True
>>> np.isscalar(memoryview(x0))
True
>>> np.isscalar(memoryview(x1))
True
# Using `.ndim`:
>>> x0.ndim
0
>>> x1.ndim
1
>>> dt0.ndim
0
>>> memoryview(x0).ndim
0
>>> memoryview(x1).ndim
1
>>> memoryview(dt0).ndim
0 So conclusion: yes, Not sure that this is worth keeping open; |
isscalar
doesn't support memoryview object:The text was updated successfully, but these errors were encountered: