From 780919075024d6a502e784bf39f100628ff84464 Mon Sep 17 00:00:00 2001 From: karibbov Date: Tue, 5 Sep 2023 23:36:42 +0200 Subject: [PATCH] __future__.annotations --- src/neps/optimizers/multi_fidelity/utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/neps/optimizers/multi_fidelity/utils.py b/src/neps/optimizers/multi_fidelity/utils.py index 6f715323..e5715770 100644 --- a/src/neps/optimizers/multi_fidelity/utils.py +++ b/src/neps/optimizers/multi_fidelity/utils.py @@ -1,4 +1,6 @@ -from typing import Any, Dict, List, Sequence, Tuple, Union +from __future__ import annotations + +from typing import Any, Sequence import pandas as pd @@ -21,8 +23,8 @@ class MFObservedData: def __init__( self, - columns: Union[List[str], None] = None, - index_names: Union[List[str], None] = None, + columns: list[str] | None = None, + index_names: list[str] | None = None, ): if columns is None: columns = [self.default_config_col, self.default_perf_col] @@ -51,7 +53,7 @@ def error_condition(self): return self.df[self.perf_col] == "error" @property - def seen_config_ids(self) -> List: + def seen_config_ids(self) -> list: return self.df.index.levels[0].to_list() @property @@ -66,8 +68,8 @@ def next_config_id(self) -> int: def add_data( self, - data: Union[List[Any], List[List[Any]]], - index: Union[Tuple[int, ...], Sequence[Tuple[int, ...]], Sequence[int], int], + data: list[Any] | list[list[Any]], + index: tuple[int, ...] | Sequence[tuple[int, ...]] | Sequence[int] | int, error: bool = False, ): """ @@ -92,8 +94,8 @@ def add_data( def update_data( self, - data_dict: Dict[str, List[Any]], - index: Union[Tuple[int, ...], Sequence[Tuple[int, ...]], Sequence[int], int], + data_dict: dict[str, list[Any]], + index: tuple[int, ...] | Sequence[tuple[int, ...]] | Sequence[int] | int, error: bool = False, ): """