Skip to content

Commit

Permalink
chore: add test for time series volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
frodehk committed Oct 27, 2023
1 parent d70412a commit 22eca81
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libecalc/common/utils/rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,18 @@ def to_volumes(self) -> TimeSeriesVolumes:


class TimeSeriesVolumes(TimeSeries[float]):
@validator("values", pre=True)
def check_length_timestep_values(cls, v: list, values, field: ModelField):
# Initially timesteps for volumes contains one more item than values
# After reindex number of timesteps equals number of values
# TODO: Ensure periodical volumes are handled in a consistent way. Why different after reindex?
if len(v) not in [len(values["timesteps"]), len(values["timesteps"]) - 1]:
raise ProgrammingError(
"Time series: number of timesteps do not match number "
"of values. Most likely a bug, report to eCalc Dev Team."
)
return v

def resample(self, freq: Frequency):
msg = (
f"{self.__repr_name__()} does not have an resample method."
Expand Down

0 comments on commit 22eca81

Please sign in to comment.