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

Timothy Hochberg tim.hochberg@ieee....
Mon Dec 10 16:46:17 CST 2007


On Dec 10, 2007 7:21 AM, Hans Meine <meine@informatik.uni-hamburg.de> wrote:

> 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.)


Why not just use minimum or maximum as needed instead of overloading clip?


-- 
.  __
.   |-\
.
.  tim.hochberg@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071210/e37bccd3/attachment.html 


More information about the Numpy-discussion mailing list