Skip to content

Commit

Permalink
Merge branch 'master' into confmat_multilabel
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Mar 29, 2021
2 parents dcdf504 + 19b77cc commit 484b9fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed when `_stable_1d_sort` to work when n >= N ([#6177](https://github.com/PyTorchLightning/pytorch-lightning/pull/6177))


- Fixed `_computed` attribute not being correctly reset ([#147](https://github.com/PyTorchLightning/metrics/pull/147))


## [0.2.0] - 2021-03-12


Expand Down
9 changes: 9 additions & 0 deletions tests/bases/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ class B(DummyListMetric):
assert isinstance(b.x, list) and len(b.x) == 0


def test_reset_compute():
a = DummyMetricSum()
assert a.x == 0
a.update(tensor(5))
assert a.compute() == 5
a.reset()
assert a.compute() == 0


def test_update():

class A(DummyMetric):
Expand Down
2 changes: 2 additions & 0 deletions torchmetrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def reset(self):
"""
This method automatically resets the metric state variables to their default value.
"""
self._computed = None

for attr, default in self._defaults.items():
current_val = getattr(self, attr)
if isinstance(default, Tensor):
Expand Down

0 comments on commit 484b9fb

Please sign in to comment.