Maximum allowed value for a numpy data type

后端 未结 2 1235
离开以前
离开以前 2020-12-24 05:16

I am working with numpy arrays of a range of data types (uint8, uint16, int16, etc.). I would like to be able to check whether a number can be represented within the limits

相关标签:
2条回答
  • 2020-12-24 05:19

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

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

    0 讨论(0)
  • 2020-12-24 05:39
    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)
    0 讨论(0)
提交回复
热议问题