[Numpy-discussion] Adding 'where' to ufunc methods?
njs at pobox.com
Wed Apr 1 16:02:52 EDT 2015
On Apr 1, 2015 12:55 PM, <josef.pktd at gmail.com> wrote:
> On Wed, Apr 1, 2015 at 3:47 PM, Nathaniel Smith <njs at pobox.com> wrote:
> > On Wed, Apr 1, 2015 at 11:34 AM, Jaime Fernández del Río
> > <jaime.frio at gmail.com> wrote:
> >> This question on StackOverflow:
> >> Got me thinking that I had finally found a use for the 'where' kwarg of
> >> ufuncs. Unfortunately it is only provided for the ufunc itself, but
> >> any of its methods.
> >> Is there any fundamental reason these were not implemented back in the
> >> Any frontal opposition to having them now?
> > The where= argument stuff was rescued from the last aborted attempt to
> > add missing value support to numpy. The only reason they aren't
> > implemented for the ufunc methods is that Mark didn't get that far.
> > +1 to adding them now.
> can you get `where` in ufuncs without missing value support?
where= is implemented since 1.7 iirc, for regular ufunc calls. I.e. you can
currently do np.add(a, b, where=mask), but not np.add.reduce(a, b,
> what's the result for ufuncs that are not reduce operations?
The operation skips over any entries where the mask is false. So if you
pass an out= array, the masked out entries will remain unchanged from
before the call; if you don't pass an out= array then one will be allocated
for you as if by calling np.empty, and then the masked out entries will
> what's the result for reduce operations along an axis if there is
> nothing there (in a row or column or ...)?
The same as a reduce operation on a zero length axis: the identity if the
ufunc has one, and an error otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion