Re: quickly looping over a 2D array?

2009-07-27 Thread Martin
On Jul 27, 12:42 pm, Peter Otten __pete...@web.de wrote: Martin wrote: I am new to python and I was wondering if there was a way to speed up the way I index 2D arrays when I need to check two arrays simultaneously? My current implementations is (using numpy) something like the

Re: quickly looping over a 2D array?

2009-07-27 Thread Peter Otten
Martin wrote: On Jul 27, 12:42 pm, Peter Otten __pete...@web.de wrote: Martin wrote: I am new to python and I was wondering if there was a way to speed up the way I index 2D arrays when I need to check two arrays simultaneously? My current implementations is (using numpy) something like

Re: quickly looping over a 2D array?

2009-07-27 Thread Martin
On Jul 27, 1:46 pm, Peter Otten __pete...@web.de wrote: Martin wrote: On Jul 27, 12:42 pm, Peter Otten __pete...@web.de wrote: Martin wrote: I am new to python and I was wondering if there was a way to speed up the way I index 2D arrays when I need to check two arrays simultaneously?

Re: quickly looping over a 2D array?

2009-07-27 Thread Peter Otten
Martin wrote: On Jul 27, 1:46 pm, Peter Otten __pete...@web.de wrote: Martin wrote: On Jul 27, 12:42 pm, Peter Otten __pete...@web.de wrote: Martin wrote: I am new to python and I was wondering if there was a way to speed up the way I index 2D arrays when I need to check two arrays

Re: quickly looping over a 2D array?

2009-07-27 Thread Martin
On Jul 27, 2:17 pm, Peter Otten __pete...@web.de wrote: Martin wrote: On Jul 27, 1:46 pm, Peter Otten __pete...@web.de wrote: Martin wrote: On Jul 27, 12:42 pm, Peter Otten __pete...@web.de wrote: Martin wrote: I am new to python and I was wondering if there was a way to speed

Re: quickly looping over a 2D array?

2009-07-27 Thread Peter Otten
Martin wrote: The statement works now, but it doesn't give the same results as my original logic, strangely!? in my logic: data = np.zeros((numrows, numcols), dtype = np.uint8, order ='C') for i in range(numrows): for j in range(numcols): if band3[i,j] == 255 or

Re: quickly looping over a 2D array?

2009-07-27 Thread Martin
On Jul 27, 4:12 pm, Peter Otten __pete...@web.de wrote: Martin wrote: The statement works now, but it doesn't give the same results as my original logic, strangely!? in my logic: data = np.zeros((numrows, numcols), dtype = np.uint8, order ='C') for i in range(numrows): for j in

Re: quickly looping over a 2D array?

2009-07-27 Thread Robert Kern
On 2009-07-27 06:24, Martin wrote: Hi, I am new to python and I was wondering if there was a way to speed up the way I index 2D arrays when I need to check two arrays simultaneously? My current implementations is (using numpy) something like the following... for i in range(numrows): for j