Re: array manipulation without for loops

2006-06-25 Thread Alex Martelli
Sheldon <[EMAIL PROTECTED]> wrote: > The following script (using your function) raised no exception so it > worked! Elegant Alex, thanx. > > res = equalize_arrays(msgtmp,ppstmp,255) # class > (ppstmp,msgtmp) = res.equalize() # class method > for i in range(int(main.xsize))

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
The following script (using your function) raised no exception so it worked! Elegant Alex, thanx. res = equalize_arrays(msgtmp,ppstmp,255) # class (ppstmp,msgtmp) = res.equalize() # class method for i in range(int(main.xsize)): for j in range(int(main.ysize)

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
Hi Alex, I will code this in a little while and get back to you. Terrific! I saw this function but I skipped over it without realizing what it could do. The Numeric doc is not very good and I am just getting into Python so your book sounds great especially since it covers Numeric. I will look int

Re: array manipulation without for loops

2006-06-25 Thread Alex Martelli
Tim Chase <[EMAIL PROTECTED]> wrote: ... > >>> all = [(x==255 or y==255) and (255, 255) or (x,y) for (x,y) > in itertools.izip(a1,a2)] > >>> b1 = [x[0] for x in all] > >>> b2 = [x[1] for x in all] > >>> a1, a2 = b1, b2 # if you want them to replace the originals > > Seems to do what I unde

Re: array manipulation without for loops

2006-06-25 Thread Alex Martelli
Sheldon <[EMAIL PROTECTED]> wrote: > Alex, > > I am using Numeric and have created 3 arrays: zero((1215,1215),Float) > Two arrays are compared and one is used to hold the mean difference > between the two compared arrays. Then I compare 290 or 340 pairs of > arrays. I know that memory is a proble

Re: array manipulation without for loops

2006-06-25 Thread Tim Chase
> I have two arrays that are of the same dimension but having 3 different > values: 255, 1 or 2. > I would like to set all the positions in both arrays having 255 to be > equal, i.e., where one array has 255, I set the same elements in the > other array to 255 and visa versa. Does anyone know how t

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
Alex, I am using Numeric and have created 3 arrays: zero((1215,1215),Float) Two arrays are compared and one is used to hold the mean difference between the two compared arrays. Then I compare 290 or 340 pairs of arrays. I know that memory is a problem and that is why I don't open all of these arra

Re: array manipulation without for loops

2006-06-25 Thread Gary Herron
Sheldon wrote: > Hi Gary, > > I am really trying to cut the time down as I have 600+ arrays with > dimensions (1215,1215) to compare and I do a lot more things with the > arrays. If I understand you correctly, there is no way around a for > loop? > Well no. I gave you two alternatives to for loo

Re: array manipulation without for loops

2006-06-25 Thread Alex Martelli
Sheldon <[EMAIL PROTECTED]> wrote: > Hi Gary, > > I am really trying to cut the time down as I have 600+ arrays with > dimensions (1215,1215) to compare and I do a lot more things with the > arrays. If I understand you correctly, there is no way around a for > loop? In pure Python (w/o extension

Re: array manipulation without for loops

2006-06-25 Thread Alex Martelli
Sheldon <[EMAIL PROTECTED]> wrote: > I have two arrays that are of the same dimension but having 3 different > values: 255, 1 or 2. > I would like to set all the positions in both arrays having 255 to be > equal, i.e., where one array has 255, I set the same elements in the > other array to 255 an

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
Hi Gary, I am really trying to cut the time down as I have 600+ arrays with dimensions (1215,1215) to compare and I do a lot more things with the arrays. If I understand you correctly, there is no way around a for loop? /Sheldon Gary Herron wrote: > Sheldon wrote: > > Hi, > > > > I have two ar

Re: array manipulation without for loops

2006-06-25 Thread Gary Herron
Sheldon wrote: > Hi, > > I have two arrays that are of the same dimension but having 3 different > values: 255, 1 or 2. > I would like to set all the positions in both arrays having 255 to be > equal, i.e., where one array has 255, I set the same elements in the > other array to 255 and visa versa.

array manipulation without for loops

2006-06-25 Thread Sheldon
Hi, I have two arrays that are of the same dimension but having 3 different values: 255, 1 or 2. I would like to set all the positions in both arrays having 255 to be equal, i.e., where one array has 255, I set the same elements in the other array to 255 and visa versa. Does anyone know how to do