-
Notifications
You must be signed in to change notification settings - Fork 36
fix: reject impossible CALYPSO atom choices #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
All three. So it would not catch a wrong fix, which is the thing worth catching here. Separately: if the guard ever regresses, this test hangs rather than fails. I reverted the predicate to the pre-PR always-false form and ran it under No pytest verdict at all — To be fair to it, the test does pin something real: that some guard fires before the retry loop for this input. Three additions would make it discriminating and safe:
|
||
| """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) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things go wrong on this line, and they are the same root cause.
It rejects valid configurations. Since
overlap ⊆ atom_choicesalways holds, this fires whenever a sub-list equals the global intersection. That is the shape of any "narrow the choices as you go" config, and of every single-sub-list config. Verified against the shipped API:The example in the error message two lines below is itself valid.
[[A,B,C],[B,C],[C]]assigns C→B→A. I ran the real equivalent,[["Li","Na","K"],["Na","K"],["K"]]: atd3ca156~1it returned['Li','Na','K']; at this head it raises. So the message has documented a legal config as forbidden since #217, and this change is what makes the code enforce that. Whatever predicate you land on, that sentence needs to go or be corrected — it is the only user-facing description of the rule, and it is wrong.It still hangs on genuinely impossible configs.
[["Li"],["Li"],["Na","K"]]has an empty global intersection, so no sub-list equals it, the guard stays silent, and the loop spins forever — I killed it at 8 seconds, exit 137. That is the same failure #356 reports, one sub-list larger. 45 of 399 swept configs behave this way.Hall's condition is the exact test; see the review body for a drop-in that I verified has zero mismatches against exhaustive search. Whichever way you go, it would be worth putting the offending
name_of_atomsand the computed intersection into the message — as written it prints neither, so a user cannot tell which sub-list tripped it.