Skip to content

Commit

Permalink
Bugfix: Serialization of PercentageDeviationUncertainty
Browse files Browse the repository at this point in the history
  • Loading branch information
andreArtelt committed Oct 25, 2024
1 parent baf8677 commit 7230780
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions epyt_flow/uncertainty/uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7230780

Please sign in to comment.