-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use torch.testing.assert_close instead of approx
The tests outputs `RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.` for torch above v1.4. The error seems to came from trying to convert tensor to scalar. Replace the pytest approx() with `torch.testing.assert_close()` to let torch handle the conversion. Use `assert_allclose()` for torch versions before 1.9.0.
- Loading branch information
Showing
2 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
torch | ||
pytest>=8,<9 | ||
pytest-cov>=2,<3 | ||
packaging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters