Albert Strasheim wrote:
> Hello all
>
> Consider the following example:
>
> In [43]: x = N.zeros((3,2))
>
> In [44]: x.flags
> Out[44]:
>   C_CONTIGUOUS : True
>   F_CONTIGUOUS : False
>   OWNDATA : True
>   WRITEABLE : True
>   ALIGNED : True
>   UPDATEIFCOPY : False
>
> In [45]: x[:,[1,0]].flags
> Out[45]:
>   C_CONTIGUOUS : False
>   F_CONTIGUOUS : True
>   OWNDATA : False
>   WRITEABLE : True
>   ALIGNED : True
>   UPDATEIFCOPY : False
>
> 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.
>   

In this case, yes.  When you use fancy-indexing with standard slicing 
(an extension that NumPy added), the implementation uses transposes 
under the covers quite often.   So, you can't rely on the output of 
fancy indexing being a C-contiguous array (even though it won't be 
referring to the same data as the original array). 

So, you are exposing an implementation detail here.  To interface to 
code that requires C-contiguous or F-contiguous data, you have to check 
the flags and make an appropriate copy.

-Travis

_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to