> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Andy Cheesman
> 
> Hi people,
> 
> If I've two numpy arrays, is there a non-looping way of finding common
> values. (the example below has identical shapes for the 
> arrays but this
> may not be the case in my scenario)
> 
> e.g
> a = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> b = array([ 5,  6,  7,  8,  9, 10, 11, 12, 13, 14])
> 
> answer = array([ 5,6,7,8,9])
> 
> Thanks
> 
> Andy

You might try sets.

http://docs.python.org/lib/types-set.html

I'm guessing that you'd need to convert the arrays to sets. Maybe
convert the arrays to lists or tuples then to sets? Maybe you might be
able to directly convert the numpy arrays to sets? I haven't used numpy,
so you'll need to experiment. 

Mike
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to