[Numpy-discussion] Learning "strides"
ndarray at mac.com
Fri Feb 3 14:05:01 CST 2006
On 2/2/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> Here's the issue. With records it is quite easy to generate strides
> that are not integer multiples of the data. For example, a record
> [('field1', 'f8),('field2', 'i2')] data-type would have floating point
> data separated by 10 bytes. When you get a view of field1 (but getting
> that attribute) you would get such a "misaligned" data.
> Look at the following:
> temp = array([(1.8,2),(1.7,3)],dtype='f8,i2')
> How would you represent that in the element-based strides report?
You are right. I cannot think of anything better than just byte-based
strides in this case. Maybe we could add a restriction
abs(strides[i]) >= itemsize? This will probably catch some of the more
common mistakes that are due to using number of elements instead
of number of bytes.
More information about the Numpy-discussion