numpy.testing.assert_array_max_ulp#
- testing.assert_array_max_ulp(a, b, maxulp=1, dtype=None)[source]#
檢查陣列的所有項目在最後一個有效位數 (Units in the Last Place, ULP) 上的差異是否最多為 N 個單位。
- 參數:
- a, barray_like
要比較的輸入陣列。
- maxulpint, optional
元素 a 和 b 在最後一個有效位數上可以不同的最大單位數。預設值為 1。
- dtypedtype, optional
如果給定,則將 a 和 b 轉換成的資料類型。預設值為 None。
- 回傳值:
- retndarray
包含 a 和 b 中項目之間可表示的浮點數數量的陣列。
- 引發:
- AssertionError
如果一個或多個元素的差異超過 maxulp。
參見
assert_array_almost_equal_nulp
比較兩個陣列相對於它們間隔的程度。
註解
對於計算 ULP 差異,此 API 不區分 NAN 的各種表示形式 (0x7fc00000 和 0xffc00000 之間的 ULP 差異為零)。
範例
>>> a = np.linspace(0., 1., 100) >>> res = np.testing.assert_array_max_ulp(a, np.arcsin(np.sin(a)))