[英]query properties of numpy dtypes
我有一個程序在運行時使用一些numpy數據類型,例如uint8
, int8
, uint16
, int16
, uint32
, int32
。
在運行時是否可以查詢這些數據類型對象並確定以下屬性?
對於ints,您可以使用iinfo
來實現所需的方式:
d = np.dtype('int8') # for example
min_value = np.iinfo(d).min
max_value = np.iinfo(d).max
signed = min_value!=0 # can also use "dtype.kind", see Jaime's comment
size = d.itemsize # see comment
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.