diff --git a/dpgen2/exploration/task/caly_task_group.py b/dpgen2/exploration/task/caly_task_group.py index 14594f38..a903f502 100644 --- a/dpgen2/exploration/task/caly_task_group.py +++ b/dpgen2/exploration/task/caly_task_group.py @@ -122,7 +122,7 @@ def set_params( for temp in name_of_atoms[1:]: overlap = overlap & set(temp) - if any(map(lambda s: (set(s) - overlap) == 0, name_of_atoms)): + if any(not (set(atom_choices) - overlap) for atom_choices in name_of_atoms): raise ValueError( f"Any sub-list should not equal with intersection, e.g. [[A,B,C], [B,C], [C]] is not allowed." ) diff --git a/tests/exploration/test_make_task_group_from_config.py b/tests/exploration/test_make_task_group_from_config.py index f9fe93be..0fc33b30 100644 --- a/tests/exploration/test_make_task_group_from_config.py +++ b/tests/exploration/test_make_task_group_from_config.py @@ -126,3 +126,15 @@ def test_make_caly_input(self): def test_caly_task_group(self): tgroup = make_calypso_task_group_from_config(self.config) self.assertTrue(isinstance(tgroup, CalyTaskGroup)) + + def test_rejects_impossible_random_atom_choices(self): + """Fail before random selection when unique choices are impossible.""" + config = { + "name_of_atoms": [["Li"], ["Li"]], + "numb_of_atoms": [10, 10], + "numb_of_species": 2, + "distance_of_ions": [[1.0, 1.0], [1.0, 1.0]], + } + + with self.assertRaisesRegex(ValueError, "intersection"): + make_calypso_task_group_from_config(config)