我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用numpy.typeDict()。
def test_iinfo_long_values(self): for code in 'bBhH': res = np.array(np.iinfo(code).max + 1, dtype=code) tgt = np.iinfo(code).min assert_(res == tgt) for code in np.typecodes['AllInteger']: res = np.array(np.iinfo(code).max, dtype=code) tgt = np.iinfo(code).max assert_(res == tgt) for code in np.typecodes['AllInteger']: res = np.typeDict[code](np.iinfo(code).max) tgt = np.iinfo(code).max assert_(res == tgt)
def test_int_raise_behaviour(self): def overflow_error_func(dtype): np.typeDict[dtype](np.iinfo(dtype).max + 1) for code in 'lLqQ': assert_raises(OverflowError, overflow_error_func, code)
def dtype_for(t): """ return my dtype mapping, whether number or name """ if t in dtype_dict: return dtype_dict[t] return np.typeDict.get(t, t)
def c2f(r, i, ctype_name): """ Convert strings to complex number instance with specified numpy type. """ ftype = c2f_dict[ctype_name] return np.typeDict[ctype_name](ftype(r) + 1j * ftype(i))