| 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") |