numpy.ndarray.strides

ndarray.strides

Tuple of bytes to step in each dimension.

The byte offset of element (i[0], i[1], ..., i[n]) in an array a is:

offset = sum(np.array(i) * a.strides)

Examples

>>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)
>>> x.strides
(32, 4, 224, 1344)
>>> i = np.array([3,5,2,2])
>>> offset = sum(i * x.strides)
>>> x[3,5,2,2]
813
>>> offset / x.itemsize
813

Previous topic

numpy.ndarray.shape

Next topic

numpy.ndarray.ndim

This Page

Quick search