-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes metric hashing * Update torchmetrics/metric.py * Apply suggestions from code review * chlog * fix test * fix decorator * fix decorator Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: thomas chaton <thomas@grid.ai> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> Co-authored-by: Nicki Skafte <skaftenicki@gmail.com> Co-authored-by: Jirka <jirka.borovec@seznam.cz> (cherry picked from commit 3257c60)
- Loading branch information
1 parent
760b888
commit 830f5c7
Showing
4 changed files
with
33 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
|
||
from tests.helpers.testers import DummyListMetric, DummyMetric | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"metric_cls", | ||
[ | ||
DummyMetric, | ||
DummyListMetric, | ||
], | ||
) | ||
def test_metric_hashing(metric_cls): | ||
"""Tests that hases are different. | ||
See the Metric's hash function for details on why this is required. | ||
""" | ||
instance_1 = metric_cls() | ||
instance_2 = metric_cls() | ||
|
||
assert hash(instance_1) != hash(instance_2) | ||
assert id(instance_1) != id(instance_2) |
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
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