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