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

Timothy Hochberg tim.hochberg at ieee.org
Tue Dec 11 10:59:45 EST 2007


On Dec 11, 2007 2:32 AM, Hans Meine <meine at informatik.uni-hamburg.de> wrote:

> Am Montag, 10. Dezember 2007 23:46:17 schrieb Timothy Hochberg:
> > > 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?
>
> You mean one of the following?
>  a.clip(min = 10, max = numpy.finfo(a.dtype).max)
>  a.clip(min = 10, max = numpy.iinfo(a.dtype).max)


No. I mean:

  numpy.maximum(a, 10)

To correspond to the above example.



>
> Three reasons:
> - this is not very concise
> - it is less efficient than specialized clip variants
>  (not much / too important though)
> - I would have to discriminate integral and floating point types
>
> How is the latter done in numpy?  Is there a good reason not to have
> numpy.rangetraits(sometype) with min/max as in iinfo/finfo?
> Should I use isinstance(mytype, int)?
>
> --
> Ciao, /  /
>     /--/
>    /  / ANS
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
.  __
.   |-\
.
.  tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20071211/57c736a4/attachment.html>


More information about the NumPy-Discussion mailing list