[Numpy-discussion] ndarray.clip only with lower or upper values?

Hans Meine meine at informatik.uni-hamburg.de
Mon Dec 10 09:21:56 EST 2007


Hi again,

I noticed that clip() needs two parameters, but wouldn't it be nice and 
straightforward to just pass min= or max= as keyword arg?

In [2]: a = arange(10)

In [3]: a.clip(min = 2, max = 5)
Out[3]: array([2, 2, 2, 3, 4, 5, 5, 5, 5, 5])

In [4]: a.clip(min = 2)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most recent 
call last)

/home/meine/<ipython console>

TypeError: function takes at least 2 arguments (1 given)

(I could simulate that by passing max = maximum_value_of(a.dtype), if that 
existed, see my other mail.)

Ciao, /  /
     /--/
    /  / ANS



More information about the NumPy-Discussion mailing list