From a8e799d36d04aea4d7896914acd6c8919762d4d4 Mon Sep 17 00:00:00 2001 From: wahadameh Date: Thu, 31 Oct 2024 15:54:12 +0100 Subject: [PATCH] Working on correcting minor problems --- requirements-dev.txt | 1 - src/antares/tsgen/ts_generator.py | 15 ++++++--------- tests/test_duration_generator.py | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6e98953..ae69777 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,6 @@ black~=23.7.0 isort~=5.12.0 -matplotlib>=3.5.1 mypy~=1.7.1 pandas-stubs pytest-cov diff --git a/src/antares/tsgen/ts_generator.py b/src/antares/tsgen/ts_generator.py index 83ac224..438dff7 100644 --- a/src/antares/tsgen/ts_generator.py +++ b/src/antares/tsgen/ts_generator.py @@ -128,9 +128,7 @@ def _check_cluster(cluster: ThermalCluster) -> None: _check_array(cluster.modulation < 0, "Hourly modulation is negative on following hours") - lengths = _check_lengths(cluster.outage_gen_params) - if len(lengths) != 1: - raise ValueError(f"Not all daily arrays have same size, got {lengths}") + _check_lengths(cluster.outage_gen_params) def _check_link_capacity(link_capacity: LinkCapacity) -> None: @@ -148,13 +146,10 @@ def _check_link_capacity(link_capacity: LinkCapacity) -> None: _check_array(link_capacity.modulation_direct < 0, "Hourly direct modulation is negative on following hours") _check_array(link_capacity.modulation_indirect < 0, "Hourly indirect modulation is negative on following hours") - lengths = _check_lengths(link_capacity.outage_gen_params) - - if len(lengths) != 1: - raise ValueError(f"Not all daily arrays have same size, got {lengths}") + _check_lengths(link_capacity.outage_gen_params) -def _check_lengths(outage_gen_params: OutageGenerationParameters) -> set[int]: +def _check_lengths(outage_gen_params: OutageGenerationParameters) -> None: lengths = { len(a) for a in [ @@ -166,7 +161,9 @@ def _check_lengths(outage_gen_params: OutageGenerationParameters) -> set[int]: outage_gen_params.npo_max, ] } - return lengths + + if len(lengths) != 1: + raise ValueError(f"Not all daily arrays have same size, got {lengths}") class OutageOutput: diff --git a/tests/test_duration_generator.py b/tests/test_duration_generator.py index 34b1d9e..14dd0a9 100644 --- a/tests/test_duration_generator.py +++ b/tests/test_duration_generator.py @@ -10,7 +10,6 @@ # # This file is part of the Antares project. -import matplotlib.pyplot as plt import pytest from antares.tsgen.duration_generator import (