Hi, On Mon, Aug 3, 2015 at 3:13 PM, Gregory Lee <grle...@gmail.com> wrote: > I agree that often you don't need to worry about the memory order. However, > it is not uncommon in medical imaging to go back and forth between a 2D or > 3D image representation and a 1D array representation (e.g. as often used in > image reconstruction algorithms). I found that the main time it was > necessary to pay careful attention to the memory layout was when converting > Matlab scripts that involve reshaping operations.
Yes, good point. A typical example would be this kind of thing: # data is a 4D array with time / volume axis last data_2d = data.reshape((-1, data.shape[-1]) For MATLAB, the columns of this array would (by default) have the values on the first axis fastest changing, then the second, then the third, whereas numpy's default is the other way round. I find I usually don't have to worry about this, because I'm later going to do: data_processed_4d = data_2d.reshape(data.shape) which will reverse the previous reshape in the correct way. But in any case - this is not directly to do with the array memory layout. You will get the same output from reshape whether the memory layout of `data` was Fortran or C. Cheers, Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion