Maximum allowed value for a numpy data type

后端 未结 2 1245
离开以前
离开以前 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: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)

提交回复
热议问题