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
Array shape is lost during as_ctypes/as_array round trip in 1.15 #11636
Comments
…eslib.as_ctypes, np.ctypeslib.as_array round trip - See numpy/numpy#11636 Fixes #746
This warning is telling you that your version of python has a broken |
I can't reproduce this - what is Can you show the result of |
In [2]: print(repr(c_arr))
<numpy.ctypeslib.c_long_Array_2_Array_1 object at 0x7f8f648ff950>
In [3]: memoryview(c_arr).format
Out[3]: '<l'
In [4]: import sys
In [5]: print(sys.version_info)
sys.version_info(major=3, minor=5, micro=3, releaselevel='final', serial=0) |
…eslib.as_ctypes, np.ctypeslib.as_array round trip (#773) - See numpy/numpy#11636 Fixes #746
Well that's pretty weird. Can you also show:
Note that |
This is in numpy 1.14
Also some warnings were printed:
This is in numpy 1.15
And this is the warnings:
Note that the |
I initially put 1.14 output by accident; you may have received a confusing email. |
I don't understand the warnings are being emitted there, but I do understand why the guess is failing:
This is caused by |
…e arrays to dtypes This fixes numpy#11636 Also adds xfailing tests for related issues
Patched at #11652 - thanks for the bug report! |
It appears that, when a 2 dimensional array's first index has a length of 1, round-tripping the array through
np.ctypeslib.as_ctypes
andnp.ctypeslib.as_array
loses the shape of the array.Here is a short repro:
Note that this did not occur in numpy v1.14. Another example of an array that doesn't round trip correctly is
[[1], [2]]
. However,[[1, 2], [3, 4]]
does round trip correctly.Note that a possibly-relevant warning which I do not understand occurs when executing the repro code:
The text was updated successfully, but these errors were encountered: