更新时间:2022-03-30 07:46:47
对于浮点数组的相等性测试可能会失败,并且assert_almost_equal
更可靠.
for floating point arrays equality test might fail and assert_almost_equal
is more reliable.
更新
一些版本以前numpy获得了assert_allclose
,现在它是我的最爱,因为它允许我们指定绝对误差和相对误差,并且不需要十进制舍入作为接近度标准.
A few versions ago numpy obtained assert_allclose
which is now my favorite since it allows us to specify both absolute and relative error and doesn't require decimal rounding as the closeness criterion.