cleanly handles so many continuous integration issues that it is not worth fooling around with obsolete
nose and legacy
One of those many areas is in the constant need to compare equality of floating point numbers.
In general computer representations of
floating point numbers have finite precision,
and so in general the fundamental arithmetic assumptions learned in elementary school about real numbers are broken, including associativity.
A practical solution to this problem is to compare numbers (scalars or arrays) to within an absolute and relative tolerance.
Widely known functions exist to compare “equality” of floating point numbers in
among other numerical languages.
provides a syntactically clean approach that may be more intuitive and readable for CI applications.
It works with scalars and arrays of all sorts including the ubiquitous
This example shows how to replace
import numpy as np from pytest import approx def test_mynums(): x = np.array([2.00000000001, 1.99999999999]) assert x == approx(2.)
Whereas with Numpy, the last line would have been
I find the Pytest syntax and appearance to be more readable.