[Numpy-discussion] Code generator bug and fix?

Charles R Harris charlesr.harris@gmail....
Tue Apr 22 09:32:13 CDT 2008

On Tue, Apr 22, 2008 at 8:15 AM, Travis E. Oliphant <oliphant@enthought.com>

> Charles R Harris wrote:
> >
> > I note that other logical operators, <, ==, do in fact return booleans
> > when operating on objects. So another fix is to write special case
> > loops for logical_{not, or, and, xor} that do the same. Perhaps a
> > ticket for an enhancement should be opened.
> There should already be special-case loops for those cases, right?
> Only the general purpose loops O_O and OO_O which were being used for
> the "method-call" on object arrays.
> Are you saying that we should actually return "boolean" arrays instead
> of object arrays for the logical operations on Object arrays?    That is
> a relevant suggestion but is a change in code.   I'm inclined not to do
> it,  because it limits the ways that logical_and can be used.  Perhaps a
> single boolean is not what is desired on output, but a whole "object" of
> them.

I'm saying we already return boolean arrays for some object arrays. For

 In [1]: x = ones(5, dtype=object)

In [2]: x
Out[2]: array([1, 1, 1, 1, 1], dtype=object)

In [3]: x == x
Out[3]: array([ True,  True,  True,  True,  True], dtype=bool)

Because there are special case loops for the comparison operators. We don't
do the same for the logical operators. I'm agnostic about this, although
objects in objects out is easy to remember.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080422/8b8e9a05/attachment.html 

More information about the Numpy-discussion mailing list