Skip to content

Commit

Permalink
Fix #234
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-steinke committed Sep 3, 2024
1 parent 63fc53b commit 79d2c0c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vessim/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def __init__(
fill_method: Literal["ffill", "bfill"] = "ffill",
column: Optional[str] = None,
):
if isinstance(actual, pd.DataFrame) and forecast is not None:
if isinstance(forecast, pd.DataFrame):
if not actual.columns.equals(forecast.columns):
raise ValueError("Column names in actual and forecast do not match.")
else:
raise ValueError("Forecast has to be a DataFrame if actual is a DataFrame.")

self.default_column = column
self._fill_method = fill_method
# Unpack index of actual dataframe
Expand Down Expand Up @@ -356,7 +363,8 @@ def _resample_to_frequency(
else:
# Actual value is used for interpolation
times = np.insert(times, 0, start_time)
data = np.insert(data, 0, self.now(start_time, column))
# https://github.com/dos-group/vessim/issues/234
data = np.insert(data, 0, self.now(start_time, None if data.ndim == 1 else column))
if resample_method == "ffill":
new_data = data[np.searchsorted(times, new_times, side="right") - 1]
elif resample_method == "nearest":
Expand Down

0 comments on commit 79d2c0c

Please sign in to comment.