m-ary logical functions
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.
On Thu, 2012-07-12 at 10:53 -0400, Neal Becker 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.
I don't think you mean m-ary. It's just a simple binary OR of more than one variable. I don't even know what a m-ary OR would mean (a bit-wise OR of the binary representation?) It's already a bit-wise OR of an array, that's the whole point (otherwise you could just use `or'!) Henry
On Thu, Jul 12, 2012 at 4:13 PM, Henry Gomersall
On Thu, 2012-07-12 at 10:53 -0400, Neal Becker 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.
I don't think you mean m-ary. It's just a simple binary OR of more than one variable. I don't even know what a m-ary OR would mean (a bit-wise OR of the binary representation?)
It's already a bit-wise OR of an array, that's the whole point (otherwise you could just use `or'!)
Different "ary": https://en.wikipedia.org/wiki/Arity -n
On Thu, 2012-07-12 at 16:21 +0100, Nathaniel Smith wrote:
On Thu, 2012-07-12 at 10:53 -0400, Neal Becker 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.
I don't think you mean m-ary. It's just a simple binary OR of more
On Thu, Jul 12, 2012 at 4:13 PM, Henry Gomersall
wrote: than one variable. I don't even know what a m-ary OR would mean (a bit-wise OR of the binary representation?)
It's already a bit-wise OR of an array, that's the whole point (otherwise you could just use `or'!)
Different "ary": https://en.wikipedia.org/wiki/Arity
haha! Apologies, my bad. Though talking about m-ary in a context like this is just damned confusing. Henry
On Thu, Jul 12, 2012 at 10:53 AM, Neal Becker
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 never had the problem that I tried to use or with more than two arguments. But I agree, it's easy to make that mistake. Instead of logical_or (logical_or (a, b), c) I usually use any((a, b, c))
On Thu, Jul 12, 2012 at 3:53 PM, Neal Becker
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
participants (5)
-
Alan G Isaac
-
Henry Gomersall
-
Martin Luessi
-
Nathaniel Smith
-
Neal Becker