Skip to content

Commit

Permalink
just some mypy fighting
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianp14 committed Oct 16, 2023
1 parent c0d25d9 commit 23d5bb3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions vessim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@ def __init__(
if isinstance(forecast, (pd.Series, pd.DataFrame)):
# Convert all indices (either one or two columns) to datetime
if isinstance(forecast.index, pd.MultiIndex):
forecast_index: pd.MultiIndex = forecast.index
for level in range(forecast.index.nlevels):
forecast.index = forecast.index.set_levels(
pd.to_datetime(forecast.index.levels[level]), level=level
forecast.index = forecast_index.set_levels(
pd.to_datetime(forecast_index.levels[level]), level=level
)
else:
forecast.index = pd.to_datetime(forecast.index)

forecast.sort_index(inplace=True)
if isinstance(forecast, pd.Series):
forecast = forecast.to_frame()
self._forecast = forecast
self._forecast: Optional[pd.DataFrame]
if isinstance(forecast, pd.Series):
self._forecast = forecast.to_frame()
else:
self._forecast = forecast # type: ignore
self._fill_method = fill_method

def zones(self) -> List:
Expand Down Expand Up @@ -247,13 +250,13 @@ def _get_zone_index_from_dataframe(self, df: pd.DataFrame, zone: Optional[str]):

def _resample_to_frequency(
self,
df: pd.DataFrame,
df: pd.Series,
start_time: DatetimeLike,
end_time: DatetimeLike,
frequency: Optional[Union[str, pd.DateOffset, timedelta]] = None,
resample_method: Optional[str] = None,
):
"""Transform dataframe into the desired frequency between start and end time."""
"""Transform series into the desired frequency between start and end time."""
frequency = pd.tseries.frequencies.to_offset(frequency)
if frequency is None:
raise ValueError(f"Frequency '{frequency}' invalid.")
Expand Down

0 comments on commit 23d5bb3

Please sign in to comment.