From 72307804f21d1ae898d6303135145b3a937c399c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Artelt?= Date: Fri, 25 Oct 2024 14:09:04 +0200 Subject: [PATCH] Bugfix: Serialization of PercentageDeviationUncertainty --- epyt_flow/uncertainty/uncertainties.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/epyt_flow/uncertainty/uncertainties.py b/epyt_flow/uncertainty/uncertainties.py index fa88beb..27c4e40 100644 --- a/epyt_flow/uncertainty/uncertainties.py +++ b/epyt_flow/uncertainty/uncertainties.py @@ -334,8 +334,16 @@ def __init__(self, deviation_percentage: float, **kwds): if not 0 < deviation_percentage < 1: raise ValueError("'deviation_percentage' must be in (0,1)") + if "low" in kwds: + del kwds["low"] + if "high" in kwds: + del kwds["high"] + super().__init__(low=1. - deviation_percentage, high=1. + deviation_percentage, **kwds) + def get_attributes(self) -> dict: + return super().get_attributes() | {"deviation_percentage": self.high - 1.} + def apply(self, data: float) -> float: data *= np.random.uniform(low=self.low, high=self.high)