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

Charles R Harris charlesr.harris at gmail.com
Thu Mar 29 19:22:45 EDT 2007


On 3/29/07, Anne Archibald <peridot.faceted at gmail.com> wrote:
>
> On 29/03/07, Robert Kern <robert.kern at 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.


I think the preferred names are C_CONTIGUOUS and F_CONTIGUOUS, for instance:

In [2]:eye(2).flags['C_CONTIGUOUS']
Out[2]:True

In [3]:eye(2).T.flags['F_CONTIGUOUS']
Out[3]:True

However, that may only be in svn at the moment. C_CONTIGUOUS is an alias for
CONTIGUOUS and
F_CONTIGUOUS is an alias for F. I think the new names are clearer than
before.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070329/e9ee02d3/attachment.html>


More information about the NumPy-Discussion mailing list