On Wed, Jun 4, 2008 at 12:16 AM, Christopher Burns <[EMAIL PROTECTED]> wrote:
> Is there a way to get the range of a numpy type?  I'd like to clamp a
> parameter to be within the range of a numpy type, np.uint8, np.uint32...
>
> Something like:
> if x > max_value_of(np.uint8):
>    x = max_value_of(np.uint8)

That kind of information is available via numpy.finfo() and numpy.iinfo():

In [12]: finfo('d').max
Out[12]: 1.7976931348623157e+308

In [13]: iinfo('i').max
Out[13]: 2147483647

In [14]: iinfo(uint8).max
Out[14]: 255


-- 
Nathan Bell [EMAIL PROTECTED]
http://graphics.cs.uiuc.edu/~wnbell/
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to