From ed16131a6e55034192b6e23610eaa701f85c87be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 17 Jun 2024 14:48:33 +0200 Subject: [PATCH] fix: ignore confusions if label is neither in `actual` nor `observed` --- src/lib/confusions.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/confusions.ts b/src/lib/confusions.ts index c021514..933aff6 100644 --- a/src/lib/confusions.ts +++ b/src/lib/confusions.ts @@ -82,10 +82,17 @@ function addMissingLabels(confusions: Array): void { } for (const { actual, observed } of confusions) { for (const l of labels) { - if (!actual.find((c) => topLevel(c) === l)) { + const hasActual = actual.find((c) => topLevel(c) === l); + const hasObserved = observed.find((c) => topLevel(c) === l); + + if (!hasActual && !hasObserved) { + continue; + } + + if (!hasActual) { actual.push(`${l}:none`); } - if (!observed.find((c) => topLevel(c) === l)) { + if (!hasObserved) { observed.push(`${l}:none`); } }