Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpgen2/exploration/task/caly_task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down
12 changes: 12 additions & 0 deletions tests/exploration/test_make_task_group_from_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)