Adding 'where' to ufunc methods?
This question on StackOverflow: http://stackoverflow.com/questions/29394377/minimum-of-numpy-array-ignoring-... 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 not for any of its methods. Is there any fundamental reason these were not implemented back in the day? Any frontal opposition to having them now? Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
Another usecase would be for MaskedArrays. ma.masked_array.min() wouldn't have to make a copy anymore (there is a github issue about that). It could just pass its mask into the where= argument of min() and be done with it. Problem would be generalizing situations where where= effectively results in "nowhere". Cheers! Ben Root On Wed, Apr 1, 2015 at 2:34 PM, Jaime Fernández del Río < jaime.frio@gmail.com> wrote:
This question on StackOverflow:
http://stackoverflow.com/questions/29394377/minimum-of-numpy-array-ignoring-...
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 not for any of its methods.
Is there any fundamental reason these were not implemented back in the day? Any frontal opposition to having them now?
Jaime
-- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, Apr 1, 2015 at 11:34 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
This question on StackOverflow:
http://stackoverflow.com/questions/29394377/minimum-of-numpy-array-ignoring-...
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 not for any of its methods.
Is there any fundamental reason these were not implemented back in the day? 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. -n -- Nathaniel J. Smith -- http://vorpus.org
On Wed, Apr 1, 2015 at 3:47 PM, Nathaniel Smith <njs@pobox.com> wrote:
On Wed, Apr 1, 2015 at 11:34 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
This question on StackOverflow:
http://stackoverflow.com/questions/29394377/minimum-of-numpy-array-ignoring-...
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 not for any of its methods.
Is there any fundamental reason these were not implemented back in the day? 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? what's the result for ufuncs that are not reduce operations? what's the result for reduce operations along an axis if there is nothing there (in a row or column or ...)? Josef
-n
-- Nathaniel J. Smith -- http://vorpus.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Apr 1, 2015 12:55 PM, <josef.pktd@gmail.com> wrote:
On Wed, Apr 1, 2015 at 3:47 PM, Nathaniel Smith <njs@pobox.com> wrote:
On Wed, Apr 1, 2015 at 11:34 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
This question on StackOverflow:
http://stackoverflow.com/questions/29394377/minimum-of-numpy-array-ignoring-...
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
not for
any of its methods.
Is there any fundamental reason these were not implemented back in the day? 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, where=mask).
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 remain uninitialized.
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. -n
participants (4)
-
Benjamin Root
-
Jaime Fernández del Río
-
josef.pktd@gmail.com
-
Nathaniel Smith