[Numpy-discussion] Why is my array not contiguous?

Jens Jørgen Mortensen jensj at fysik.dtu.dk
Fri Jul 7 02:51:56 CDT 2006


Hi!

With numpy-0.9.9.2726, I do this:

 >>> x = arange(4)
 >>> y = x[newaxis, :]

I would expect both arrays to be contiguous:

 >>> x.flags.contiguous, y.flags.contiguous
(True, False)

Shouldn't y be contiguous?  Maybe it's because of the strange strides:

 >>> y.strides
(0, 4)
 >>> y.strides = (16, 4)
 >>> y.flags.contiguous
True

Jens Jørgen









More information about the Numpy-discussion mailing list