How to get the range of valid Numpy data types? How to get the range of valid Numpy data types? numpy numpy

How to get the range of valid Numpy data types?


Quoting from a numpy discussion list:

That information is available via numpy.finfo() and numpy.iinfo():In [12]: finfo('d').maxOut[12]: 1.7976931348623157e+308In [13]: iinfo('i').maxOut[13]: 2147483647In [14]: iinfo('uint8').maxOut[14]: 255

Link here.


You can use numpy.iinfo(arg).max to find the max value for integer types of arg, and numpy.finfo(arg).max to find the max value for float types of arg.

>>> numpy.iinfo(numpy.uint64).min0>>> numpy.iinfo(numpy.uint64).max18446744073709551615L>>> numpy.finfo(numpy.float64).max1.7976931348623157e+308>>> numpy.finfo(numpy.float64).min-1.7976931348623157e+308

iinfo only offers min and max, but finfo also offers useful values such as eps (the smallest number > 0 representable) and resolution (the approximate decimal number resolution of the type of arg).