[SciPy-dev] max and argmax

dmitrey openopt at ukr.net
Fri Aug 3 11:10:05 EDT 2007


Thank you, I understood the solution, but I meant a func from numpy or 
scipy core.

Regards, D.

Robert Kern wrote:
> dmitrey wrote:
>   
>> hi all,
>> in MATLAB
>> [val ind] = max(arr)
>> returns both max and index of the max element.
>>
>> In Python I use
>> ind = argmax(arr)
>> val = arr(ind)
>> is it possible to avoid 2 lines, i.e. somehow to replace by single one?
>>     
>
> def matlablike_max(arr):
>     ind = argmax(arr)
>     return ind, arr[ind]
>
> ind, val = matlablike_max(arr)
>
>   




More information about the SciPy-Dev mailing list