From e9ea04f74c2262343fbde5d5aed46ffc15404e29 Mon Sep 17 00:00:00 2001 From: Jostein Solaas <33114722+jsolaas@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:49:47 +0200 Subject: [PATCH] fix: set_regularity fixture (#213) Set regularity should not raise error when value is wrong, and I think we need to raise ValueError for pydantic to pick it up correctly, if we wanted to raise an error. --- src/libecalc/common/utils/rates.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libecalc/common/utils/rates.py b/src/libecalc/common/utils/rates.py index 67c7a70886..e16bdc4cd4 100644 --- a/src/libecalc/common/utils/rates.py +++ b/src/libecalc/common/utils/rates.py @@ -648,8 +648,9 @@ def set_regularity(cls, regularity: Optional[List[float]], values: Dict[str, Any return regularity try: return [1] * len(values["values"]) - except KeyError as e: - raise KeyError("Failed to set default values for regularity. 'Values' of timeseries is not defined") from e + except KeyError: + # 'Values' of timeseries is not defined. Not this validators responsibility. + return [] def __add__(self, other: TimeSeriesRate) -> TimeSeriesRate: # Check for same unit