-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
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:
import numpy as np
fields = [('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 works
print(aligned_array[:]) # <--- raises view would access data parent array doesn't ownThe cause of the error is likely due to the loss of the aligned attribute at
Line 502 in b65cdbf
| return obj.view(dtype=(self.dtype.type, obj.dtype.fields)) |
aligned_dtype is 8 while the nonaligned_dtype has itemsize 5.Metadata
Metadata
Assignees
Labels
No labels