Skip to content

Commit

Permalink
improved python version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
attila-balint-kul committed Jun 22, 2023
1 parent 4547681 commit 421f18f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/enfobench/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.10"
__version__ = "0.0.11"
10 changes: 4 additions & 6 deletions src/enfobench/evaluation/_cross_validate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union, List, Optional

import pandas as pd
from tqdm import tqdm
Expand Down Expand Up @@ -44,13 +42,13 @@ def generate_cutoff_dates(


def cross_validate(
model: Model | ForecastClient,
model: Union[Model, ForecastClient],
start: pd.Timestamp,
horizon: pd.Timedelta,
step: pd.Timedelta,
y: pd.Series,
level: list[int] | None = None,
freq: str | None = None,
level: Optional[List[int]] = None,
freq: Optional[str] = None,
) -> pd.DataFrame:
"""Cross-validate a model.
Expand Down
8 changes: 4 additions & 4 deletions src/enfobench/evaluation/_evaluate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from typing import Callable, Dict

import pandas as pd

Expand All @@ -24,8 +24,8 @@ def evaluate_metric_on_forecast(forecast: pd.DataFrame, metric: Callable) -> flo


def evaluate_metrics_on_forecast(
forecast: pd.DataFrame, metrics: dict[str, Callable]
) -> dict[str, float]:
forecast: pd.DataFrame, metrics: Dict[str, Callable]
) -> Dict[str, float]:
"""Evaluate multiple metrics on a single forecast.
Parameters:
Expand Down Expand Up @@ -71,7 +71,7 @@ def evaluate_metric_on_forecasts(forecasts: pd.DataFrame, metric: Callable) -> p


def evaluate_metrics_on_forecasts(
forecasts: pd.DataFrame, metrics: dict[str, Callable]
forecasts: pd.DataFrame, metrics: Dict[str, Callable]
) -> pd.DataFrame:
"""Evaluate multiple metrics on a set of forecasts made at different cutoff points.
Expand Down
7 changes: 3 additions & 4 deletions src/enfobench/evaluation/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import io
from typing import Dict, Union, Optional, List

import pandas as pd
import requests
Expand Down Expand Up @@ -39,9 +38,9 @@ def predict(
horizon: int,
y: pd.Series,
# X: pd.DataFrame,
level: list[int] | None = None,
level: Optional[List[int]] = None,
) -> pd.DataFrame:
params: dict[str, int | list[int]] = {
params: Dict[str, Union[int, List[int]]] = {
"horizon": horizon,
}
if level is not None:
Expand Down
8 changes: 3 additions & 5 deletions src/enfobench/evaluation/protocols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from enum import Enum
from typing import Any, Protocol
from typing import Any, Protocol, Optional, List

import pandas as pd
from pydantic import BaseModel
Expand Down Expand Up @@ -32,8 +30,8 @@ def predict(
self,
h: int,
y: pd.Series,
X: pd.DataFrame | None = None,
level: list[int] | None = None,
X: Optional[pd.DataFrame] = None,
level: Optional[List[int]] = None,
**kwargs,
) -> pd.DataFrame:
...
6 changes: 2 additions & 4 deletions src/enfobench/evaluation/server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import io
from typing import Annotated, List
from typing import Annotated, List, Optional

import pandas as pd
import pkg_resources
Expand Down Expand Up @@ -33,7 +31,7 @@ async def predict(
horizon: int,
y: Annotated[bytes, File()],
# X: Annotated[bytes, File()],
level: List[int] | None = Query(None),
level: Optional[List[int]] = Query(None),
):
y_df = pd.read_parquet(io.BytesIO(y))
# X_df = pd.read_parquet(io.BytesIO(X))
Expand Down

0 comments on commit 421f18f

Please sign in to comment.