From 72662994f4aadc9295b75f704a3c2bbffecf6ae7 Mon Sep 17 00:00:00 2001 From: Ramon Winterhalder <35335120+ramonpeter@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:19:34 +0200 Subject: [PATCH 1/2] Handle zero or non-finite error in __str__ method Relevant fix when working with Bayesian Neural networks which by construction gets std=0 for some validphys quantities --- src/reportengine/floatformatting.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/reportengine/floatformatting.py b/src/reportengine/floatformatting.py index 235d84f..7cfb54e 100644 --- a/src/reportengine/floatformatting.py +++ b/src/reportengine/floatformatting.py @@ -83,5 +83,8 @@ class ValueErrorTuple(NamedTuple): value: numbers.Real error: numbers.Real def __str__(self): + if self.error == 0 or not np.isfinite(np.log10(self.error)): + value = int(self.value) if self.value == int(self.value) else round(self.value, 4) + return f'{value}±0' valstr, errstr = format_value_error(self.value, self.error) return f'{valstr}±{errstr}' From 1956c99c4429579245b462e277fcf5d25805e462 Mon Sep 17 00:00:00 2001 From: Ramon Winterhalder <35335120+ramonpeter@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:26:09 +0200 Subject: [PATCH 2/2] Handle non-finite values in string representation Fix the failing build --- src/reportengine/floatformatting.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/reportengine/floatformatting.py b/src/reportengine/floatformatting.py index 7cfb54e..402b3ab 100644 --- a/src/reportengine/floatformatting.py +++ b/src/reportengine/floatformatting.py @@ -84,6 +84,8 @@ class ValueErrorTuple(NamedTuple): error: numbers.Real def __str__(self): if self.error == 0 or not np.isfinite(np.log10(self.error)): + if not np.isfinite(self.value): + return f'{self.value}±0' value = int(self.value) if self.value == int(self.value) else round(self.value, 4) return f'{value}±0' valstr, errstr = format_value_error(self.value, self.error)