fix: infer optional CALYPSO inputs - #383
Conversation
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Infer atomic numbers and a covalent-radius distance matrix when optional CALYPSO fields are omitted. Closes deepmodeling#357 Coding-Agent: Codex Codex-Version: codex-cli 0.149.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh
262334f to
3a037c0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #383 +/- ##
=======================================
Coverage 84.43% 84.43%
=======================================
Files 104 104
Lines 6110 6111 +1
=======================================
+ Hits 5159 5160 +1
Misses 951 951 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Retracted. This review was produced without running the mandated /code-review fan-out (the loop skill's section 2); the substitute process used instead has since been shown to miss findings and, in one case, to state a verified-sounding falsehood. Re-reviewing properly.
wanghan-iapcm
left a comment
There was a problem hiding this comment.
The fix is right: with the pre-PR source, a flat name_of_atoms that omits either field crashes in make_calypso_input (TypeError: object of type 'NoneType' has no len()), and this closes that. Blocking only on the test, which cannot detect a wrong default.
The test does not pin the distance values
The substance of this change is choosing numeric defaults, but the only assertions on the matrix are shape == (2, 2) and > 0. I mutated the PR's own lines and re-ran the module each time:
* 0.7 -> * 7.0 (10x wrong minimum distance) Ran 5 tests ... OK
radius index + 1 (every element reads its neighbour's radius) OK
if isinstance(distance_of_ions, dict) -> if False (dict override loop dropped) OK
self.distance_of_ions = temp_distance_mtx * 0 + 0.01 (constant matrix) OK
All four pass. Only a mutant on the atomic-number inference (+1 on line 148) is caught, so the atomic_number == [3, 57] assertion is doing its job; the distance half is not.
For the Li/La config already in the test, the exact matrix through your code path is
np.testing.assert_allclose(
task_group.distance_of_ions, [[1.79, 2.34], [2.34, 2.90]]
)which kills the first, second and fourth mutants. The third (the dict-override loop being dropped) needs one more case: nothing anywhere in tests/ pins a computed value for a distance_of_ions dict, and this PR restructures that loop while the description says it preserves per-element overrides. {"Li": 2.0} on the same config gives [[2.8, 2.85], [2.85, 2.9]]; asserting that pins the override path too.
Not blocking
- A mismatched
numb_of_species(e.g. 3 with two names) now raises a bareIndexErrorfrom the generation loop, where before it reached the assert incaly_input.pythat prints the offending values. Such a config was always fatal, so this is message quality only; anumb_of_species != len(self.name_of_atoms)check above the loop would restore it. - On merge order: this conflicts with #382 only in the test file (both append at the end); the source hunks merge cleanly. #405 merges cleanly with this PR.
| task_group = make_calypso_task_group_from_config(config) | ||
|
|
||
| self.assertEqual(task_group.atomic_number, [3, 57]) | ||
| self.assertEqual(task_group.distance_of_ions.shape, (2, 2)) |
There was a problem hiding this comment.
These two assertions only establish that a square, positive matrix was produced. I mutated the source four ways (0.7 -> 7.0; radius index +1; dict-override loop replaced by if False; matrix replaced by a constant 0.01) and all five tests stayed green each time.
Please pin the values instead. For this Li/La config:
np.testing.assert_allclose(
task_group.distance_of_ions, [[1.79, 2.34], [2.34, 2.90]]
)and one dict case, since no test in the repo pins an override value and this PR restructures that loop: distance_of_ions={"Li": 2.0} on the same config gives [[2.8, 2.85], [2.85, 2.9]].
The atomic_number == [3, 57] line above is fine; it does catch an off-by-one in the symbol table.
Summary
name_of_atomswhen omittedTests
PYTHONPATH=tests python -m unittest -v tests.exploration.test_make_task_group_from_config.TestMakeCalyTaskGroupFromConfig.test_infers_optional_atomic_numbers_and_distances tests.exploration.test_make_task_group_from_config.TestMakeCalyTaskGroupFromConfig.test_caly_task_groupruff format --check dpgen2/exploration/task/caly_task_group.py tests/exploration/test_make_task_group_from_config.pyisort --check-only dpgen2/exploration/task/caly_task_group.py tests/exploration/test_make_task_group_from_config.pygit diff --checkCloses #357
Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh