[Numpy-discussion] .data doesn't account for .transpose()?

Anne Archibald peridot.faceted@gmail....
Thu Mar 29 17:48:25 CDT 2007


On 29/03/07, Robert Kern <robert.kern@gmail.com> wrote:
> Glen W. Mabey wrote:
>
> > So, would that imply that a .copy() should be done first on any array
> > that you want to access .data on?
>
> Or even ascontiguousarray().

I'd like to point out that the numpy usage of the word "contiguous" is
a bit misleading: while naively one would expect it to mean that the
data were contiguous in memory, what it actually means is that they
are contiguous and the indexing is C-ordered:

In [7]: a = arange(5)

In [8]: a.flags["CONTIGUOUS"]
Out[8]: True

In [9]: a[::-1].flags["CONTIGUOUS"]
Out[9]: False

In [10]: eye(2).flags["CONTIGUOUS"]
Out[10]: True

In [11]: transpose(eye(2)).flags["CONTIGUOUS"]
Out[11]: False

There's no help for it now, I suppose.

Anne


More information about the Numpy-discussion mailing list