Skip to content

Commit

Permalink
reformating imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Oct 29, 2024
1 parent ab5c787 commit a52d692
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black~=24.3.0
black~=23.7.0
isort~=5.12.0
matplotlib>=3.5.1
mypy~=1.7.1
Expand Down
3 changes: 2 additions & 1 deletion src/antares/tsgen/duration_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion src/antares/tsgen/random_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class RNG(ABC):
"""

@abstractmethod
def next(self) -> float: ...
def next(self) -> float:
...


class PythonRNG(ABC):
Expand Down
39 changes: 22 additions & 17 deletions src/antares/tsgen/ts_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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]
Expand Down

0 comments on commit a52d692

Please sign in to comment.