-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
In the commit 2293b43 a test for numpy.lib.stride_tricks.as_strided() was added in array.py checking that it preserves a structured dtype. It works for the rather simple type there, but stops working for types with padding set through offsets parameter:
import numpy
from numpy.lib.stride_tricks import as_strided
dtype = numpy.dtype({
'names':['i1','nested','i2'],
'formats':['<u4',[('v', '<u8')],'<u4'],
'offsets':[0,8,16], 'itemsize':24})
arr = numpy.zeros((128,), dtype)
print(dtype)
print(new_arr.dtype)
Output:
{'names':['i1','nested','i2'], 'formats':['<u4',[('v', '<u8')],'<u4'], 'offsets':[0,8,16], 'itemsize':24}
[('i1', '<u4'), ('f1', 'V4'), ('nested', [('v', '<u8')]), ('i2', '<u4'), ('f4', 'V4')]
Apparently, as_strided() adds some dummy fields in this case and removes offsets. The alternative version of as_strided() in array.py does preserve them, but since the numpy one passes the test, it does not get invoked.
Is it the planned behavior?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels