From e7ab1275946032f1bc2f306959ce84797797fe65 Mon Sep 17 00:00:00 2001 From: Sigurd Borge Date: Fri, 29 Nov 2024 15:40:42 +0100 Subject: [PATCH] Linting after rebase --- src/antares/model/area.py | 2 +- src/antares/service/base_services.py | 1 + src/antares/service/local_services/area_local.py | 15 ++++++++++----- .../antares/services/local_services/test_area.py | 16 ++++++++-------- .../services/local_services/test_study.py | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/antares/model/area.py b/src/antares/model/area.py index c1fa814e..e797486e 100644 --- a/src/antares/model/area.py +++ b/src/antares/model/area.py @@ -378,4 +378,4 @@ def read_thermal_clusters( def read_hydro( self, ) -> Hydro: - return self._area_service.read_hydro(self.id) \ No newline at end of file + return self._area_service.read_hydro(self.id) diff --git a/src/antares/service/base_services.py b/src/antares/service/base_services.py index 87c9611d..42e09304 100644 --- a/src/antares/service/base_services.py +++ b/src/antares/service/base_services.py @@ -310,6 +310,7 @@ def read_areas(self) -> list[Area]: """ pass + class BaseLinkService(ABC): @abstractmethod def create_link( diff --git a/src/antares/service/local_services/area_local.py b/src/antares/service/local_services/area_local.py index 06594f3c..1712b3ad 100644 --- a/src/antares/service/local_services/area_local.py +++ b/src/antares/service/local_services/area_local.py @@ -316,8 +316,14 @@ def delete_renewable_clusters(self, area: Area, renewable_clusters: List[Renewab def delete_st_storages(self, area: Area, storages: List[STStorage]) -> None: raise NotImplementedError - - def _read_timeseries(self, ts_file_type: TimeSeriesFileType, study_path: Path, area_id: Optional[str] = None, constraint_id: Optional[str] = None) -> pd.DataFrame: + + def _read_timeseries( + self, + ts_file_type: TimeSeriesFileType, + study_path: Path, + area_id: Optional[str] = None, + constraint_id: Optional[str] = None, + ) -> pd.DataFrame: file_path = study_path / ( ts_file_type.value if not (area_id or constraint_id) @@ -330,10 +336,10 @@ def _read_timeseries(self, ts_file_type: TimeSeriesFileType, study_path: Path, a _time_series = pd.DataFrame() return _time_series - + def get_load_matrix(self, area: Area) -> pd.DataFrame: return self._read_timeseries(TimeSeriesFileType.LOAD, self.config.study_path, area_id=area.id) - + def get_solar_matrix(self, area: Area) -> pd.DataFrame: raise NotImplementedError @@ -362,4 +368,3 @@ def read_areas(self) -> List[Area]: ) ) return areas - diff --git a/tests/antares/services/local_services/test_area.py b/tests/antares/services/local_services/test_area.py index 6c2fd0c8..782ae6ef 100644 --- a/tests/antares/services/local_services/test_area.py +++ b/tests/antares/services/local_services/test_area.py @@ -14,8 +14,6 @@ import typing as t -import pytest - from configparser import ConfigParser from io import StringIO from pathlib import Path @@ -1106,6 +1104,7 @@ def test_k_and_translation_txt_is_empty_by_default(self, local_study, fr_load): actual_file_path = study_path.joinpath(Path("input") / "load" / "prepro" / "fr" / f"{file}.txt") assert actual_file_path.read_text() == "" + class TestReadArea: def test_read_areas_local(self, local_study_w_areas): study_path = local_study_w_areas.service.config.study_path @@ -1130,12 +1129,13 @@ def _write_file(_file_path, _time_series) -> None: for area in areas: expected_time_serie = pd.DataFrame( - [ - [-9999999980506447872, 0, 9999999980506447872], - [0, area.id, 0], - ] - , dtype="object") - + [ + [-9999999980506447872, 0, 9999999980506447872], + [0, area.id, 0], + ], + dtype="object", + ) + file_path = study_path / "input" / "load" / "series" / f"load_{area.id}.txt" _write_file(file_path, expected_time_serie) diff --git a/tests/antares/services/local_services/test_study.py b/tests/antares/services/local_services/test_study.py index 5ae7455b..0b632032 100644 --- a/tests/antares/services/local_services/test_study.py +++ b/tests/antares/services/local_services/test_study.py @@ -14,6 +14,7 @@ import logging import os import time +import typing as t from configparser import ConfigParser from pathlib import Path @@ -88,7 +89,6 @@ from antares.service.local_services.st_storage_local import ShortTermStorageLocalService from antares.service.local_services.thermal_local import ThermalLocalService from antares.tools.ini_tool import IniFileTypes -from antares.tools.time_series_tool import TimeSeriesFileType class TestCreateStudy: