-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
calling multiple times numpy.ctypeslib.as_array(pointer, shape) always uses the same shape (Trac #2079) #2671
Comments
I would fix this if I knew how to. cheers |
I suppose you can, but votes don't write code so it won't directly affect
|
Is it still of interest to fix this? I had a look at it and found doing
in This works if |
Everything behaves a lot better if we let the array constructor handle it, which will use the ctypes PEP3118 support. Bugs this fixes: * Stale state being attached to pointer objects (fixes numpygh-2671, closes numpygh-6214) * Weird failure modes on structured arrays (fixes-10978) * A regression in numpygh-10882 (fixes numpygh-10968)
Everything behaves a lot better if we let the array constructor handle it, which will use the ctypes PEP3118 support. Bugs this fixes: * Stale state being attached to pointer objects (fixes numpygh-2671, closes numpygh-6214) * Weird failure modes on structured arrays (fixes-10978) * A regression in numpygh-10882 (fixes numpygh-10968)
Original ticket http://projects.scipy.org/numpy/ticket/2079 on 2012-03-13 by trac user pieleric, assigned to unknown.
The latest version of numpy supports numpy.ctypeslib.as_array() for a ctypes.POINTER. However, when using numpy.ctypeslib.as_array() on a pointer multiple times in a row with different shapes, it's always the shape of the first call which is used.
Example:
We would expect b.shape == (10,10) .
The bug is in as_array() and prep_pointer(). They are too much a copy-paste of the case of an ndarray: only create the array_interface if it is not yet there. For an ndarray this works fine as the array_interface is saved on the type. For a pointer, it should be updated every time.
So, I propose something like this:
BTW, the description of as_array() should be updated to mention the "shape" parameter instead of the "size" parameter.
The text was updated successfully, but these errors were encountered: