[SciPy-user] comparing two lists/arrays

Robert Cimrman cimrman3@ntc.zcu...
Wed Jul 15 07:32:02 CDT 2009


Hi Nicky,

nicky van foreest wrote:
> Hi,
> 
> Given two vectors x and y, the (perhaps) common mathematical
> definition of x < y is that x_i < y_i for all i.  Thus, the
> mathematical comparison x <y returns just one boolean, not an array of
> booleans for each x_i < y_i.  I implemented this behavior as
> prod(less(X,Y)) (I use less to be able to deal with lists X and Y
> also). Is there perhaps a more straighforward/elegant/readible way to
> achieve the same behavior?

assuming x, y are numpy arrays: (x < y).all()

r.


More information about the SciPy-user mailing list