From 83808a2f1eb64cf4199c05525a83257e115c5387 Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Mon, 24 Aug 2026 03:26:12 +0800 Subject: [PATCH] fix: preserve LAMMPS configuration indices Copy task-group configuration and only supply an empty conf_idx default when the caller omitted the field. Closes #358 Coding-Agent: Codex Codex-Version: codex-cli 0.149.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- .../task/make_task_group_from_config.py | 3 ++- .../test_make_task_group_from_config.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dpgen2/exploration/task/make_task_group_from_config.py b/dpgen2/exploration/task/make_task_group_from_config.py index 2859ac8f..b11300d7 100644 --- a/dpgen2/exploration/task/make_task_group_from_config.py +++ b/dpgen2/exploration/task/make_task_group_from_config.py @@ -635,7 +635,8 @@ def make_lmp_task_group_from_config( ): # Work around the required conf_idx. # May not be a good design!!! - config["conf_idx"] = [] if "conf_idx" not in config else None + config = config.copy() + config.setdefault("conf_idx", []) config = lmp_normalize(config) config = config_strip_confidx(config) if config["type"] == "lmp-md": diff --git a/tests/exploration/test_make_task_group_from_config.py b/tests/exploration/test_make_task_group_from_config.py index f9fe93be..d91a99a2 100644 --- a/tests/exploration/test_make_task_group_from_config.py +++ b/tests/exploration/test_make_task_group_from_config.py @@ -58,6 +58,21 @@ def test_npt(self): ) self.assertTrue(isinstance(tgroup, NPTTaskGroup)) + def test_npt_preserves_explicit_conf_idx(self): + """Keep caller configuration indices intact during normalization.""" + config = { + "type": "lmp-md", + "Ts": [100], + "conf_idx": [2], + } + + tgroup = make_lmp_task_group_from_config( + self.numb_models, self.mass_map, config + ) + + self.assertTrue(isinstance(tgroup, NPTTaskGroup)) + self.assertEqual(config["conf_idx"], [2]) + def test_template(self): tgroup = make_lmp_task_group_from_config( self.numb_models, self.mass_map, self.config_template