Skip to content

Commit

Permalink
BUG/TST: fix unit test broken by pytest 7.0, fixes #464
Browse files Browse the repository at this point in the history
fixes `test_onehot` in test_functional.py,
that fails because of how `pytest.approx` was used.

A recent change enforces the correct usage:
pytest-dev/pytest#9061

Fixed by using `pytest.approx` as the error message suggests
  • Loading branch information
NickleDave committed Mar 14, 2022
1 parent f340542 commit 9c04459
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_nn/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_onehot():
# convert labels to one hot tensor
one_hot = F.one_hot(labels, num_classes)

assert pytest.approx(one_hot[0, labels[0, 0, 0], 0, 0].item(), 1.0)
assert pytest.approx(one_hot[0, labels[0, 1, 0], 1, 0].item(), 1.0)
assert pytest.approx(one_hot[1, labels[1, 0, 0], 0, 0].item(), 1.0)
assert pytest.approx(one_hot[1, labels[1, 1, 0], 1, 0].item(), 1.0)
assert 1.0 == pytest.approx(one_hot[0, labels[0, 0, 0], 0, 0].item())
assert 1.0 == pytest.approx(one_hot[0, labels[0, 1, 0], 1, 0].item())
assert 1.0 == pytest.approx(one_hot[1, labels[1, 0, 0], 0, 0].item())
assert 1.0 == pytest.approx(one_hot[1, labels[1, 1, 0], 1, 0].item())

0 comments on commit 9c04459

Please sign in to comment.