arildsen, I have used
numpy.allclose
to test for approximate equality in Python for years, but I recently foundpytest.approx
better, because it lets Pytest interpret the result. For example, withnumpy.allclose
:> assert np.allclose(result, 3.061, atol=1e-3, rtol=1e-3)
E assert False
E + where False = <function allclose at 0x7f8fea7efa60>(1.4872, 3.061, atol=0.001, rtol=0.001)
E + where <function allclose at 0x7f8fea7efa60> = np.allclose