diff --git a/src/libs/antares/study/scenario-builder/TSnumberData.cpp b/src/libs/antares/study/scenario-builder/TSnumberData.cpp index 2b35738421..4616c33c5b 100644 --- a/src/libs/antares/study/scenario-builder/TSnumberData.cpp +++ b/src/libs/antares/study/scenario-builder/TSnumberData.cpp @@ -395,8 +395,6 @@ bool thermalTSNumberData::apply(Study& study) // WARNING: We may have some thermal clusters with the `mustrun` option auto clusterCount = (uint)area.thermal.clusterCount(); - const uint tsGenCountThermal = get_tsGenCount(study); - for (uint clusterIndex = 0; clusterIndex != clusterCount; ++clusterIndex) { auto& cluster = *(area.thermal.clusters[clusterIndex]); @@ -404,9 +402,13 @@ bool thermalTSNumberData::apply(Study& study) assert(clusterIndex < pTSNumberRules.width); const auto& col = pTSNumberRules[clusterIndex]; - logprefix.clear() << "Thermal: Area '" << area.name << "', cluster: '" << cluster.name() + uint tsGenCount = cluster.tsGenBehavior == LocalTSGenerationBehavior::forceNoGen ? + cluster.series.timeSeries.width : get_tsGenCount(study); + + logprefix.clear() << "Thermal: area '" << area.name << "', cluster: '" << cluster.name() << "': "; - ret = ApplyToMatrix(errors, logprefix, *cluster.series, col, tsGenCountThermal) && ret; + ret = ApplyToMatrix(errors, logprefix, cluster.series, col, tsGenCount) && ret; + } return ret; } diff --git a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp index 9268bab171..c262d0195d 100644 --- a/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp +++ b/src/tests/src/libs/antares/study/scenario-builder/test-sc-builder-file-read-line.cpp @@ -386,4 +386,25 @@ BOOST_AUTO_TEST_CASE(on_link_area2_area3_and_on_year_19__ntc_TS_number_6_is_chos BOOST_CHECK_EQUAL(link_23->timeseriesNumbers[0][yearNumber.to()], tsNumber.to() - 1); } +// ======================== +// Tests on TSNumberData +// ======================== +BOOST_FIXTURE_TEST_CASE(thermalTSNumberData, Fixture) +{ + ScenarioBuilder::thermalTSNumberData tsdata; + tsdata.attachArea(area_1); + tsdata.reset(*study); + tsdata.setTSnumber(thCluster_12.get(), 2, 22); + tsdata.setTSnumber(thCluster_12.get(), 5, 32); //out of bounds + + study->parameters.nbTimeSeriesThermal = 1; + thCluster_12->tsGenBehavior = LocalTSGenerationBehavior::forceNoGen; + thCluster_12->series.timeSeries.resize(30, 8760); + + tsdata.apply(*study); + + BOOST_CHECK_EQUAL(thCluster_12->series.timeseriesNumbers[0][2], 21); + BOOST_CHECK_EQUAL(thCluster_12->series.timeseriesNumbers[0][5], 0); +} + BOOST_AUTO_TEST_SUITE_END()