[SciPy-Dev] extended functionality of max/min ufuncs
Ralf Gommers
ralf.gommers at gmail.com
Sat Sep 8 13:12:41 EDT 2012
On Thu, Aug 23, 2012 at 4:28 PM, Tom Grydeland <tom.grydeland at gmail.com>wrote:
> Hi all,
>
> I'm working on a system to translate (EXELIS/ITTVIS/RSI) IDL to
> Python/Numpy. The results are close to usable for many purposes, but
> some simple constructs are causing snags I was hoping you could help
> me with.
>
> IDL's MAX function supports a second (output) argument which will
> contain the index of the maximum value. One can write
>
> PRINT, MAX(x, id), id
>
> to get the value and index of the maximum element. In Numpy, I could do
>
> id = np.argmax(x); print x[id], id
>
> to get the same results in two statements. However, I can give MAX an
> extra keyword /NAN to tell it to ignore NaN and infinities. In Numpy,
> I have np.nanmax, but no np.nanargmax.
>
> In addition, MAX has the output keywords MIN=value and
> SUBSCRIPT_MIN=index to return the minimum value and its index from the
> same function call. Similarly, MIN has output keywords MAX=value and
> SUBSCRIPT_MAX=index, so I can get max/min values and their indices
> (ignoring NaNs) in a single call -- in Numpy I would need two calls,
> two indexing operations, one temporary array of values and one of
> indices.
>
> Would it be hard to add similar functionality to Numpy's min() and
> max() functions? Is it desirable?
>
You may get more responses on the numpy mailing list. I think adding
nanargmin/nanargmax is fine, and shouldn't be hard. Putting min/argmin
keywords into max and vice versa looks weird to me.
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20120908/bb76d467/attachment.html>
More information about the SciPy-Dev
mailing list