[Numpy-discussion] m-ary logical functions

Nathaniel Smith njs at pobox.com
Thu Jul 12 13:45:52 EDT 2012


On Thu, Jul 12, 2012 at 3:53 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
> I've been bitten several times by this.
>
> logical_or (a, b, c)
>
> is silently accepted when I really meant
>
> logical_or (logical_or (a, b), c)
>
> because the logic functions are binary, where I expected them to be m-ary.
>
> Dunno if anything can be done about it.
>
> Sure would like it if they were m-ary and out was a kw arg.

I'd actually like to see out= as a kw-only arg. But I don't know how
we could get there; there's a ton of code in numpy itself that passes
'out' as a positional argument, and surely even more out there in the
world. I think some of the backwards-compatibility goals thrown about
on the list lately are... impractical... but this would still be a
fairly disruptive change. We could add another ufunc method, I guess,
like
  np.logical_or.areduce(a, b, c)

For that matter, it'd be super useful to be able to write np.dot(a, b,
c, d), with the bonus that we could dynamically pick the fastest way
to evaluate it ... unfortunately it looks like we've already shipped
support for out= as a positional argument in np.dot too (added in
1.6).

-N



More information about the NumPy-Discussion mailing list