# [Numpy-discussion] order flag again

Travis Oliphant oliphant at ee.byu.edu
Mon Mar 27 14:25:03 CST 2006

```Zachary Pincus wrote:

>> The reason for the order flag is that it is needed to interpret  what
>> you think a reshape operation should do.   How should the  reshape
>> method think the data is stored.  That is the intended  meaning of
>> the reshape flag.
>> The FORTRAN flag on the array means the strides are actually
>> equivalent to FORTRAN order
>> The CONTIGUOUS flag on the array means the strides are actually
>> equilvalent to C-CONTIGUOUS order.
>> [...]
>> To do what Tim suggests would require the addition of an additional
>> flag (call it the ORDER flag) on the array that would be carried
>> dimensional sequence of bytes.
>> Such an approach is possible, of course.
>
>
>
> Does this mean that if I create a new array with FORTRAN order from
> the numpy.array() function, every time I reshape that array I need to
> tell reshape to use FORTRAN order? That seems a bit odd...

Yes, that is what it means.   Doing anything else leads to a host of
problems.   Let me illustrate.

a = rand(10,3)
b = a.transpose()
b.flags  # b is now in Fortran order
b.ravel()  # do you really want this to now be interpreted in
FORTRAN-order.  I didn't think so.

What this illustrates is that the FORTRAN and CONTIGUOUS flags on the
array are just special cases of the strides (and in fact can be updated
from the strides at any time).   But, an ORDER flag would be an
independent concept that could be set and reset at will.  The ORDER flag
is only necessary when somebody is interpreting the array as a linear
sequence of bytes.

If the ORDER flag is added, then the Array iterator would also need to
be updated, to recognize and respect the order flag.  Right now, the
array iterator (a.flat) is always C-contiguous.

>
> Yet the text above seems to suggests that arrays will not know what
> order their own bytes are in, and thus would need to be told whether
> they should be reshaped like FORTRAN or C memory blocks.
>
> I assume I'm misinterpreting something here?

It wasn't until a few weeks ago that I think I really understood the
difference between ORDER='FORTRAN' and flags & FORTRAN == True.

The order information is really an additional but related piece of
information .

The example above illustrates how you could have flags & FORTRAN == True
but order == 'C'

-Travis

```