[SciPy-dev] array logical ops error?

Ed Schofield schofield at ftw.at
Tue Nov 1 06:02:24 CST 2005



Travis Oliphant wrote:
> > Robert Cimrman apparently wrote:
> >
> >>is this the expected behaviour?
> >>IMHO (b * c) == (b and c), (b + c) == (b or c) should hold...
> >
> >I expected the Boolean operations to yield
> >element-by-element comparisons.  What are they??  In
> >contrast, the + and * operators give the expected results.
> >
>
> This is a Python deal.  It would be nice if b and c did the same thing
> as b * c, but Python does not allow overloading of the "and" and "or"
> operators (A PEP to say it should would be possible).
>
> Thus, "b and c" evaluates the truth of b and the truth of c as a whole
> (not elementwise), and there is no way to over-ride this.

Hmmm.  Could we somehow get "b and c" to return a simple boolean rather
than an array of booleans?  This would be more consistent.  At the moment
it's totally mad: "b and c" is different to "c and b" ;)

-- Ed




More information about the Scipy-dev mailing list