Skip to content

Commit

Permalink
Merge branch 'fix_#234' of github.com:dos-group/vessim into fix_#234
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-steinke committed Sep 9, 2024
2 parents 79d2c0c + b2cb601 commit 50f7bbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 2 additions & 6 deletions tests/test_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def hist_signal_single(self) -> vs.HistoricalSignal:
@pytest.fixture
def hist_signal_forecast(self) -> vs.HistoricalSignal:
index = pd.date_range("2023-01-01T00:00:00", "2023-01-01T01:00:00", freq="20T")
actual = pd.DataFrame(
{"a": [1, 5, 3, 2], "b": [0, 1, 2, 3], "c": [4, 3, 2, 7]}, index=index
)
actual = pd.DataFrame({"a": [1, 5, 3, 2], "b": [0, 1, 2, 3]}, index=index)

forecast_data = [
["2023-01-01T00:00:00", "2023-01-01T00:10:00", 2, 2.5],
Expand Down Expand Up @@ -294,12 +292,10 @@ def test_forecast_with_frequency(
# Complicated because np.nan == np.nan is False
assert forecast.keys() == expected.keys()
assert all(
np.isnan(expected[k]) if np.isnan(forecast[k])
else forecast[k] == expected[k]
np.isnan(expected[k]) if np.isnan(forecast[k]) else forecast[k] == expected[k]
for k in forecast.keys()
)


def test_forecast_fails_if_column_not_specified(self, hist_signal):
with pytest.raises(ValueError):
hist_signal.forecast(
Expand Down
4 changes: 3 additions & 1 deletion vessim/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ def _resample_to_frequency(
# Actual value is used for interpolation
times = np.insert(times, 0, start_time)
# https://github.com/dos-group/vessim/issues/234
data = np.insert(data, 0, self.now(start_time, None if data.ndim == 1 else column))
data = np.insert(
data, 0, self.now(start_time, None if len(self._actual) == 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 50f7bbc

Please sign in to comment.