You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
error when making view of a recarray of an aligned record dtype #6459
A TypeError: view would access data parent array doesn't own is raised when a view is created from a recarray and its dtype is an aligned record. The following code demonstrate this error on py3.4 numpy1.10:
importnumpyasnpfields= [('a', np.float32), ('b', np.int8)]
nonaligned_dtype=np.dtype(fields)
print(nonaligned_dtype, nonaligned_dtype.type)
aligned_dtype=np.dtype(fields, align=True)
print(aligned_dtype, aligned_dtype.type)
nonaligned_array=np.recarray(1, dtype=nonaligned_dtype)
aligned_array=np.recarray(1, dtype=aligned_dtype)
print(nonaligned_array.dtype)
print(aligned_array.dtype)
print(nonaligned_array[:]) # nonaligned record worksprint(aligned_array[:]) # <--- raises view would access data parent array doesn't own
The cause of the error is likely due to the loss of the aligned attribute at
Activity
ahaldane commentedon Oct 12, 2015
Thanks for the report, it's good to know this problem comes up in the real world.
Yes, that line should really read
This is fixed in #6053. If that PR does not get into 1.11, we should have a separate PR with just that fix.
BUG: recarrays viewed as subarrays don't convert to np.record type
BUG: recarrays viewed as subarrays don't convert to np.record type
BUG: recarrays viewed as subarrays don't convert to np.record type