[Numpy-discussion] nasty bug in 1.8.0??

Sebastian Berg sebastian at sipsolutions.net
Mon Dec 2 18:37:42 EST 2013

On Mon, 2013-12-02 at 18:15 -0500, Jim Bosch wrote:
> > If your arrays are contiguous, you don't really need the strides
> (use the itemsize instead). How is ndarray broken by this?
> ndarray is broken by this change because it expects the stride to be a
> multiple of the itemsize (I think; I'm just looking at code here, as I
> haven't had time to build NumPy 1.8 yet to test this); it has a
> slightly more restricted model for what data can look like than NumPy
> has, and it's easier to always just look at the stride for all sizes
> rather than special-case for size=1.  I think that means the bug is
> ndarray's (indeed, it's probably the kind of bug this new behavior was
> intended to catch, as I should be handling the case of
> non-itemsize-multiple strides more gracefully even when size > 1), and
> I'm working on a fix for it there now.
Most bugs I saw were just simply assuming:

arr.strides[-1] == arr.itemsize

when the array is C-contiguous, and could be fixed by just using

Unless you need to calculate contiguous flags which are compatible to
NumPy with NPY_RELAXED_STRIDES_CHECKING (i.e. cython had this problem
since its memoryview would reject numpy's contiguous arrays as not
contiguous), you should not need to special case anything.

- Sebastian
> Thanks, Neil, for bringing this to my attention, and to all the NumPy
> dev's for help in explaining what's going on.
> Jim
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list