Re: [SciPy-dev] about numpy.max() and numpy.min() - isn't it a bug?
I use the min and max from numpy (from numpy import *) Ok, maybe they are same as python buildins But ordinary users usually use min and max, not amin and amax, so for to prevent the bug mentioned either they somehow should be warned, or the behavior of the numpy.min and max should be set to always produce numpy.array (for more safety). Also, I guess it's possible to contact python developers that wrote python min and max and ask them to yield numpy.array (when any of min/max args is numpy.array) instead of python type. Also, I think the behavior of the +/- operators (to yield python type) is not optimal. Suppose I have x = (4.4*t+myNumpyArr).tolist() So I should care does myNumpyArr is of size > 1 or not. Of course, there are funcs like atleast1d or something like that but users begin to use that ones only when some time have been elapsed to find and fix the bug. Same to amax/amin vs max/min. //my 2 cents, D. Darren Dale wrote: On Tuesday 14 August 2007 11:41:51 am Dmitrey Kroshko wrote: Hi all, as for me I think the behavior of the func is not optimal from numpy import * max(array(2.), 0) array(2.0) max(array(-2.), 0) 0 You are not using numpy's amax and amin, but the python builtins. import numpy numpy.amin(numpy.array(-2.), 0) -2.0
On Tue, 14 Aug 2007, Dmitrey Kroshko apparently wrote:
I use the min and max from numpy (from numpy import *)
No, Darren is giving you the answer. See below. There are two problems. One problem is that numpy.max exists for historical reason. Another problem is that numpy.max is not import when you use import *. As the saying goes: "That hurts!" "So don't do it!" I.e., adopt practices that ensure you know the namespace you are using. Cheers, Alan Isaac Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import numpy from numpy import * help(numpy.max) Help on function amax in module numpy.core.fromnumeric:
amax(a, axis=None, out=None) Return the maximum of 'a' along dimension axis.
help(max) Help on built-in function max in module __builtin__:
max(...) max(iterable[, key=func]) -> value max(a, b, c, ...[, key=func]) -> value With a single iterable argument, return its largest item. With two or more arguments, return the largest argument.
participants (2)
-
Alan G Isaac -
Dmitrey Kroshko