On the indexing order in (numpy) arrays

2008-10-09 Thread Almar Klein
Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? This is reversed in Matlab too, because Matlab is a matrix package and matrix are often used this way.

Re: On the indexing order in (numpy) arrays

2008-10-09 Thread Robert Kern
Almar Klein wrote: Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? This is reversed in Matlab too, because Matlab is a matrix package and matrix

Re: On the indexing order in (numpy) arrays

2008-10-09 Thread Terry Reedy
Almar Klein wrote: Hi, I was wondering... Say we have a np.ndarray A of two dimensions (a grayscale image for example). If we want to access x:2, y:3, we have to do A[3,2]. Why is the order of x and y reversed? Because images are stored by rows, not by columns. So column 3, row 2, is row

Re: On the indexing order in (numpy) arrays

2008-10-09 Thread Almar Klein
Basically, we want a[i][j] == a[i,j]. Since there is no literal syntax for numpy arrays, we need to be able to convert from a sequence of sequences to an array. The indexing needs to correspond between the two. Thanks for the reply. I guess that explains the *why*... Adopt the numpy order.

Re: On the indexing order in (numpy) arrays

2008-10-09 Thread Robert Kern
Almar Klein wrote: Basically, we want a[i][j] == a[i,j]. Since there is no literal syntax for numpy arrays, we need to be able to convert from a sequence of sequences to an array. The indexing needs to correspond between the two. Thanks for the reply. I guess that explains