From a52d69255dc0d258797122fd6ef5206896b6d02c Mon Sep 17 00:00:00 2001 From: wahadameh Date: Tue, 29 Oct 2024 11:18:05 +0100 Subject: [PATCH] reformating imports --- requirements-dev.txt | 2 +- src/antares/tsgen/duration_generator.py | 3 +- src/antares/tsgen/random_generator.py | 3 +- src/antares/tsgen/ts_generator.py | 39 ++++++++++++++----------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index dcb9e63..404c97c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -black~=24.3.0 +black~=23.7.0 isort~=5.12.0 matplotlib>=3.5.1 mypy~=1.7.1 diff --git a/src/antares/tsgen/duration_generator.py b/src/antares/tsgen/duration_generator.py index 9d67ba9..4bc229b 100644 --- a/src/antares/tsgen/duration_generator.py +++ b/src/antares/tsgen/duration_generator.py @@ -30,7 +30,8 @@ class DurationGenerator(ABC): """ @abstractmethod - def generate_duration(self, day: int) -> int: ... + def generate_duration(self, day: int) -> int: + ... class GeneratorWrapper(DurationGenerator): diff --git a/src/antares/tsgen/random_generator.py b/src/antares/tsgen/random_generator.py index b705ed0..9bd3416 100644 --- a/src/antares/tsgen/random_generator.py +++ b/src/antares/tsgen/random_generator.py @@ -21,7 +21,8 @@ class RNG(ABC): """ @abstractmethod - def next(self) -> float: ... + def next(self) -> float: + ... class PythonRNG(ABC): diff --git a/src/antares/tsgen/ts_generator.py b/src/antares/tsgen/ts_generator.py index 189209e..2bed74d 100644 --- a/src/antares/tsgen/ts_generator.py +++ b/src/antares/tsgen/ts_generator.py @@ -17,7 +17,7 @@ import numpy.typing as npt from numpy import dtype, ndarray -from antares.tsgen.duration_generator import ProbabilityLaw, make_duration_generator +from antares.tsgen.duration_generator import DurationGenerator, ProbabilityLaw, make_duration_generator from antares.tsgen.random_generator import RNG, MersenneTwisterRNG # probabilities above FAILURE_RATE_EQ_1 are considered certain (equal to 1) @@ -159,7 +159,7 @@ def _check_cluster(cluster: ThermalCluster) -> None: raise ValueError(f"Not all daily arrays have same size, got {lengths}") -def _check_link_capacity(link_capacity: LinkCapacity): +def _check_link_capacity(link_capacity: LinkCapacity) -> None: if link_capacity.nominal_capacity <= 0: raise ValueError(f" {link_capacity.nominal_capacity}.") if len(link_capacity.modulation_direct) < 0: @@ -338,7 +338,7 @@ def __init__(self, rng: RNG = MersenneTwisterRNG(), days: int = 365) -> None: self.rng = rng self.days = days - def _compare_apparent_PO(self, current_available_units: int, po_candidates: int, stock: int): + def _compare_apparent_PO(self, current_available_units: int, po_candidates: int, stock: int) -> tuple[int, int]: candidate = po_candidates + stock if 0 <= candidate <= current_available_units: po_candidates = candidate @@ -352,8 +352,14 @@ def _compare_apparent_PO(self, current_available_units: int, po_candidates: int, return po_candidates, stock def _generate_outages( - self, outage_gen_params: OutageGenerationParameters, log, log_size, logp, number_of_timeseries, output - ): + self, + outage_gen_params: OutageGenerationParameters, + log: ndarray[Any, dtype], + log_size: int, + logp: ndarray[Any, dtype], + number_of_timeseries: int, + output: OutputTimeseries, + ) -> None: daily_fo_rate = _compute_failure_rates(outage_gen_params.fo_rate, outage_gen_params.fo_duration) daily_po_rate = _compute_failure_rates(outage_gen_params.po_rate, outage_gen_params.po_duration) _combine_failure_rates(daily_fo_rate, daily_po_rate) @@ -450,17 +456,17 @@ def generate_time_series_for_clusters( def output_generation( self, - outage_gen_params, - fo_drawer, - fod_generator, - log, - log_size, - logp, - number_of_timeseries, - output, - po_drawer, - pod_generator, - ): + outage_gen_params: OutageGenerationParameters, + fo_drawer: ForcedOutagesDrawer, + fod_generator: DurationGenerator, + log: ndarray[Any, dtype], + log_size: int, + logp: ndarray[Any, dtype], + number_of_timeseries: int, + output: OutputTimeseries, + po_drawer: PlannedOutagesDrawer, + pod_generator: DurationGenerator, + ) -> None: # dates now = 0 # current number of PO and AU (avlaible units) @@ -470,7 +476,6 @@ def output_generation( # stock > 0 number of PO pushed back, stock < 0 number of PO antcipated stock = 0 for ts_index in range(-2, number_of_timeseries): - for day in range(self.days): # = return of units wich were in outage = current_planned_outages -= logp[now]