diff --git a/src/antares/tsgen/ts_generator.py b/src/antares/tsgen/ts_generator.py index 379710a..36eb4ad 100644 --- a/src/antares/tsgen/ts_generator.py +++ b/src/antares/tsgen/ts_generator.py @@ -91,7 +91,7 @@ def _check_cluster(cluster: ThermalCluster) -> None: _check_array(cluster.fo_duration < 0, "Forced outage duration is negative on following days") _check_array(cluster.po_rate < 0, "Planned failure rate is negative on following days") _check_array(cluster.po_rate > 1, "Planned failure rate is greater than 1 on following days") - _check_array(cluster.po_duration < 0, "Planned outage duration is negative on following days") + _check_array(cluster.po_duration <= 0, "Planned outage duration is null or negative on following days") _check_array(cluster.modulation < 0, "Hourly modulation is negative on following hours") lengths = { diff --git a/tests/test_unit.py b/tests/test_unit.py index 6bee9a9..7b3c7b5 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -62,24 +62,22 @@ def base_cluster_365_days(): def test_ts_gen_with_matrix_full_of_zeros(rng): days = 365 - cluster = ThermalCluster( - unit_count=10, - nominal_power=100, - modulation=np.ones(dtype=float, shape=8760), - fo_law=ProbabilityLaw.UNIFORM, - fo_volatility=0, - po_law=ProbabilityLaw.UNIFORM, - po_volatility=0, - fo_duration=10 * np.zeros(dtype=int, shape=days), - fo_rate=0.2 * np.zeros(dtype=float, shape=days), - po_duration=10 * np.zeros(dtype=int, shape=days), - po_rate=np.zeros(dtype=float, shape=days), - npo_min=np.zeros(dtype=int, shape=days), - npo_max=10 * np.zeros(dtype=int, shape=days), - ) - generator = ThermalDataGenerator(rng=rng, days=days) - # asserts the method _compute_failure_rates doesn't return NaN values which led to the generation failing. - generator.generate_time_series(cluster, 1) + with pytest.raises(ValueError, match="Planned outage duration is null or negative on following days"): + ThermalCluster( + unit_count=10, + nominal_power=100, + modulation=np.ones(dtype=float, shape=8760), + fo_law=ProbabilityLaw.UNIFORM, + fo_volatility=0, + po_law=ProbabilityLaw.UNIFORM, + po_volatility=0, + fo_duration=10 * np.zeros(dtype=int, shape=days), + fo_rate=0.2 * np.zeros(dtype=float, shape=days), + po_duration=10 * np.zeros(dtype=int, shape=days), + po_rate=np.zeros(dtype=float, shape=days), + npo_min=np.zeros(dtype=int, shape=days), + npo_max=10 * np.zeros(dtype=int, shape=days), + ) def test_invalid_fo_rates(rng, base_cluster_365_days):