From: Norbert N. <Nor...@gm...> - 2005-01-10 13:30:27
|
Am Montag, 10. Januar 2005 11:46 schrieb John Hunter: > I'm happy with Fernando's proposed names amin, amax, around, etc. If > everyone else is too, I propose Andrew implement his patch, provide > the compatibility names, and update the relevant docs to advertise > this prominently: API_CHANGES, CHANGELOG, tutorial and users guide. > Particularly in the latter two, I think we should warn people about > the potential performance hit of using the builtin min, max and > friends on large arrays. There might be a solution that avoids the performance hit: there should not be any problem with pylab offering an optimized set of min, max, etc. as long as their signature is identical to the builtins and the behavior only extends them. Something along the line of: def min(*args, **kwargs): if args == (): raise TypeError, "min() takes at least 1 argument (0 given)" if len(args) == 1 and type(args[0]) is ArrayType: axis=kwargs.pop('axis',0) res = minimum.reduce(args[0],axis) else: res = __builtin__.min(*args) if len(kwargs)>0: raise TypeError, ( "min() got an unexpected keyword argument '%s'" %kwargs.keys()[0] ) return res Probably, one could even avoid separate amin, amax, etc. functions. The user just has to be aware that the axis can only be given as keyword argument. -- _________________________________________Norbert Nemec Bernhardstr. 2 ... D-93053 Regensburg Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199 eMail: <No...@Ne...> |