Skip to content

Commit 4d372d2

Browse files
committed
Merge pull request #3467 from cimarronm/mlab_stride_bugfix
BUG : Bugfix in mlab for strided views of np.arrays
2 parents b892838 + 7b88fcf commit 4d372d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/mlab.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,10 @@ def stride_windows(x, n, noverlap=None, axis=0):
584584
step = n - noverlap
585585
if axis == 0:
586586
shape = (n, (x.shape[-1]-noverlap)//step)
587-
strides = (x.itemsize, step*x.itemsize)
587+
strides = (x.strides[0], step*x.strides[0])
588588
else:
589589
shape = ((x.shape[-1]-noverlap)//step, n)
590-
strides = (step*x.itemsize, x.itemsize)
590+
strides = (step*x.strides[0], x.strides[0])
591591
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
592592

593593

@@ -633,10 +633,10 @@ def stride_repeat(x, n, axis=0):
633633

634634
if axis == 0:
635635
shape = (n, x.size)
636-
strides = (0, x.itemsize)
636+
strides = (0, x.strides[0])
637637
else:
638638
shape = (x.size, n)
639-
strides = (x.itemsize, 0)
639+
strides = (x.strides[0], 0)
640640

641641
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
642642

0 commit comments

Comments
 (0)