[Numpy-discussion] Question about flags of fancy indexed array

Stefan van der Walt stefan at sun.ac.za
Wed May 23 10:36:37 EDT 2007


On Wed, May 23, 2007 at 09:49:08AM -0400, Anne Archibald wrote:
> On 23/05/07, Albert Strasheim <fullung at gmail.com> wrote:
>
> > Is it correct that the F_CONTIGUOUS flag is set in the case of the fancy
> > indexed x? I'm running NumPy 1.0.3.dev3792 here.
> 
> Numpy arrays are always stored in contiguous blocks of memory with
> uniform strides. The "CONTIGUOUS" flag actually means something
> totally different, which is unfortunate, but in any case, "fancy
> indexing" can't be done as a simple reindexing operation. It must make
> a copy of the array. So what you're seeing is the flags of a fresh new
> array, created from scratch (and numpy always creates arrays in C
> order internally, though that is an implementation detail you should
> not rely on).

That still doesn't explain

In [41]: N.zeros((3,2))[:,[0,1]].flags
Out[41]: 
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True <<<<<<<<<<<
  OWNDATA : False     <<<<<<<<<<<
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

vs.

In [40]: N.zeros((3,2),order='F')[:,[0,1]].flags
Out[40]: 
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False <<<<<<<<<<
  OWNDATA : False      <<<<<<<<<<
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

Maybe the Fortran-ordering quiz at

http://mentat.za.net/numpy/quiz

needs an update! :)

Cheers
Stéfan



More information about the NumPy-Discussion mailing list