[Numpy-discussion] Logical Selector

Geoffrey Zhu gzhu@peak6....
Wed Jul 18 14:06:40 CDT 2007


Hi Everyone,

I am finding that numpy cannot operate on boolean arrays. For example,
the following does not work:

x=3Darray([(1,2),(2,1),(3,1),(4,1)])

x[x[:,0]>x[:,1] and x[1:]>1,:]

It gives me an syntax error:

-------------------
Traceback (most recent call last):
  File "<pyshell#74>", line 1, in <module>
    x[x[:,0]>x[:,1] and x[1:]>1,:]
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
-------------------

However, this is not what I want. I want a "piece-wise" "AND" operation
on the two boolean vectors. In other words, the row is selected if both
are true. How do I accomplish this?

Many thanks,
Geoffrey

P.S The disclaimer is automatically generated by the mail server.





_______________________________________________________=0A=
=0A=
The  information in this email or in any file attached=0A=
hereto is intended only for the personal and confiden-=0A=
tial  use  of  the individual or entity to which it is=0A=
addressed and may contain information that is  propri-=0A=
etary  and  confidential.  If you are not the intended=0A=
recipient of this message you are hereby notified that=0A=
any  review, dissemination, distribution or copying of=0A=
this message is strictly prohibited.  This  communica-=0A=
tion  is  for information purposes only and should not=0A=
be regarded as an offer to sell or as  a  solicitation=0A=
of an offer to buy any financial product. Email trans-=0A=
mission cannot be guaranteed to be  secure  or  error-=0A=
free. P6070214


More information about the Numpy-discussion mailing list