Skip to content

Commit

Permalink
add test wrt pytest-dev#3695 checking numpy array tolerance args
Browse files Browse the repository at this point in the history
  • Loading branch information
abrammer committed Jul 24, 2018
1 parent 75db608 commit 514ca6f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testing/python/approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ def test_numpy_array(self):
assert actual == approx(list(expected), rel=5e-7, abs=0)
assert actual != approx(list(expected), rel=5e-8, abs=0)

def test_numpy_tolerance_args(self):
"""
quick check that numpy rel/abs args are handled correctly
for comparison against an np.array
"""
np = pytest.importorskip("numpy")
expected = 100
actual = 99
assert actual != pytest.approx(expected, abs=0.1, rel=0)
assert np.array(actual) != pytest.approx(expected, abs=0.1, rel=0)

assert actual == pytest.approx(expected, abs=0, rel=0.01)
assert np.array(actual) == pytest.approx(expected, abs=0, rel=0.1)

def test_numpy_array_wrong_shape(self):
np = pytest.importorskip("numpy")

Expand Down

0 comments on commit 514ca6f

Please sign in to comment.