comparing two arrays

Sheldon shejo284 at gmail.com
Mon Jun 19 08:49:41 EDT 2006


Hi,

I have two arrays that are identical and contain 1s and zeros. Only the
ones are valid and I need to know where both arrays have ones in the
same position. I thought logical_and would work but this example proves
otherwise:
>>> a = [0,1,2,5,6,6]
>>> b = [5,4,1,6,4,6]
>>> Numeric.logical_and(a==6,b==6)
0
>>> Numeric.where(a==b,1,0)
0
>>> Numeric.where(a==6 and b==6,1,0)
0

The where() statement is also worhtless here. Does anyone have any
suggestion on how to do this?

Thanks in advance,
Sheldon




More information about the Python-list mailing list