Maximum allowed value for a numpy data type

Solution 1:

min_value = np.iinfo(im.dtype).min
max_value = np.iinfo(im.dtype).max

docs:

  • np.iinfo (machine limits for integer types)
  • np.finfo (machine limits for floating point types)

Solution 2:

You're looking for numpy.iinfo for integer types. Documentation here.

There's also numpy.finfo for floating point types. Documentation here.