MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_numpy_expecting_nan

Method test_numpy_expecting_nan

testing/python/approx.py:666–682  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

664 assert op(approx(np.array(expected), abs=_abs, rel=_rel), np.array(actual))
665
666 def test_numpy_expecting_nan(self):
667 np = pytest.importorskip("numpy")
668 examples = [
669 (eq, nan, nan),
670 (eq, -nan, -nan),
671 (eq, nan, -nan),
672 (ne, 0.0, nan),
673 (ne, inf, nan),
674 ]
675 for op, a, x in examples:
676 # Nothing is equal to NaN by default.
677 assert np.array(a) != approx(x)
678 assert a != approx(np.array(x))
679
680 # If ``nan_ok=True``, then NaN is equal to NaN.
681 assert op(np.array(a), approx(x, nan_ok=True))
682 assert op(a, approx(np.array(x), nan_ok=True))
683
684 def test_numpy_expecting_inf(self):
685 np = pytest.importorskip("numpy")

Callers

nothing calls this directly

Calls 1

approxFunction · 0.90

Tested by

no test coverage detected