Skip to content

Commit

Permalink
add test for metrics without valid input
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBinder committed Oct 14, 2024
1 parent e8c7520 commit e25276b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/taskmodules/test_re_text_classification_with_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,5 +1813,20 @@ def test_configure_model_metric(documents, taskmodule):
},
)

# no targets and no predictions
metric.reset()
no_targets = {"labels": torch.tensor([0, 0, 0])}
no_predictions = {"labels": torch.tensor([0, 0, 0])}
metric.update(no_targets, no_predictions)
state = get_metric_state(metric)

# TODO: assert state
assert state
# TODO: assert metric.compute()
torch.testing.assert_close(
metric.compute(),
{},
)

# ensure that the metric can be pickled
pickle.dumps(metric)

0 comments on commit e25276b

Please sign in to comment.