From 388e2263919f23aa227f74d5b6c98eaeafd6bcd6 Mon Sep 17 00:00:00 2001 From: qubixes <44498096+qubixes@users.noreply.github.com> Date: Thu, 12 Mar 2020 15:06:35 +0100 Subject: [PATCH] Fix a crash if WSS/RRF values are NA (#2) --- asreviewcontrib/statistics/__init__.py | 2 +- asreviewcontrib/statistics/statistics.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/asreviewcontrib/statistics/__init__.py b/asreviewcontrib/statistics/__init__.py index 0797efd..dfe49df 100644 --- a/asreviewcontrib/statistics/__init__.py +++ b/asreviewcontrib/statistics/__init__.py @@ -16,4 +16,4 @@ from asreviewcontrib.statistics.statistics import DataStatistics from asreviewcontrib.statistics.entrypoint import StatEntryPoint -__version__ = "0.2.0" +__version__ = "0.2.1" diff --git a/asreviewcontrib/statistics/statistics.py b/asreviewcontrib/statistics/statistics.py index 8fef941..dd1a176 100644 --- a/asreviewcontrib/statistics/statistics.py +++ b/asreviewcontrib/statistics/statistics.py @@ -96,10 +96,16 @@ def __str__(self): if len(results["wss"]) + len(results["rrf"]) > 0: stat_str += "----------- WSS/RRF -----------\n" for wss_at, wss_val in results["wss"].items(): - wss_val_str = f"{wss_val:.2f}" + if wss_val is not None: + wss_val_str = f"{wss_val:.2f}" + else: + wss_val_str = "NA" stat_str += f"WSS@{wss_at: <3}: {wss_val_str: <5} %\n" for rrf_at, rrf_val in results["rrf"].items(): - rrf_val_str = f"{rrf_val:.2f}" + if rrf_val is not None: + rrf_val_str = f"{rrf_val:.2f}" + else: + rrf_val_str = "NA" stat_str += f"RRF@{rrf_at: <3}: {rrf_val_str: <5} %\n" return stat_str