diff --git a/revscoring/scoring/statistics/classification/counts.py b/revscoring/scoring/statistics/classification/counts.py index 0ddbbce0..966fc5d3 100644 --- a/revscoring/scoring/statistics/classification/counts.py +++ b/revscoring/scoring/statistics/classification/counts.py @@ -74,7 +74,7 @@ def format_str(self, path_tree, **kwargs): formatted = "counts (n={0}):\n".format(self['n']) table_data = [ [repr(label), self['labels'][label], '-->'] + - [lstats[a][p] for a in [True, False] for p in [True, False]] + [lstats[a][p] for p in [True, False] for a in [True, False]] for label, lstats in self['predictions'].items()] table_str = tabulate( table_data, headers=['label', 'n', '', 'TP', 'FP', 'FN', 'TN']) diff --git a/tests/scoring/statistics/classification/tests/test_multilabel_counts.py b/tests/scoring/statistics/classification/tests/test_multilabel_counts.py index 9ec4a563..5b80d441 100644 --- a/tests/scoring/statistics/classification/tests/test_multilabel_counts.py +++ b/tests/scoring/statistics/classification/tests/test_multilabel_counts.py @@ -17,10 +17,13 @@ def test_counts(): print(c.format_str({})) print(json.dumps(c.format_json({}), indent=2)) + bar_c = c.format_str({}).split("\n")[4] + assert c.lookup("n") == 100 assert c.lookup("labels.foo") == 30 assert c.lookup("predictions.foo.true.false") == 0 assert c.lookup("predictions.foo.true.true") == 30 assert c.lookup("predictions.bar.false.true") == 20 + assert bar_c.lstrip() == "'bar' 80 --> 30 20 50 0" pickle.loads(pickle.dumps(c))