[Numpy-discussion] order flag again

Travis Oliphant oliphant at ee.byu.edu
Mon Mar 27 11:49:05 CST 2006

Tim Hochberg wrote:

> I notice that some methods of the array object, notably reshape, take 
> the order flag. I think this is a mistake. At this point, x.reshape() 
> should always be returning a view.

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 

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.

For a non-contiguous array, you may still have a sense of which 
dimension you think ought to vary the fastest.  This kind of "sense" is 
not needed all the time --- only on certain operations.  For these 
operations, the order keyword needs to be present. 

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 around to 
tell everybody how to think about this array as a one-dimensional 
sequence of bytes. 

Such an approach is possible, of course.


More information about the Numpy-discussion mailing list