lorenzo bolla wrote:

> Hi all,
> I've got an easy question for you. I looked in Travis' book, but I 
> couldn't figure out the answer...
>  
> If I have an array1D (obtained reading a stream of numbers with 
> numpy.fromfile) like that:
>  
> In [150]: data
> Out[150]: array([ 2.,  3.,  4.,  3.,  4.,  5.,  4.,  5.,  6.,  5.,  
> 6.,  7.], dtype=float32)
>  
> I want it to be considered as "Fortran ordered", so that when I do:
>  
> In [151]: data.shape = (3,4)
>  
> I want to get:
>  
> array([[ 2.,  3.,  4.,  5.],
>        [ 3.,  4.,  5.,  6.],
>        [ 4.,  5.,  6.,  7.]], dtype=float32)
>  
> But I get:
>  
> array([[ 2.,  3.,  4.,  3.],
>        [ 4.,  5.,  4.,  5.],
>        [ 6.,  5.,  6.,  7.]], dtype=float32)
>  
> How can I do that?


The Fortran orderness is a property of changing the shape from 1-d to 
2-d.  Assigning to the shape only allows you to do C-ordering. 

However, the reshape method allows a key-word argument:

data.reshape(3,4,order='F')

will give you what you want.

-Travis





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

Reply via email to