Skip to content

fix: infer optional CALYPSO inputs - #383

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/issue-357-calypso-defaults
Open

fix: infer optional CALYPSO inputs#383
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/issue-357-calypso-defaults

Conversation

@njzjz-bot

Copy link
Copy Markdown

Summary

  • infer atomic numbers from name_of_atoms when omitted
  • generate the required distance matrix from the maintained covalent-radius table
  • preserve explicit lists and per-element radius overrides
  • cover the fully omitted optional-field case through task generation

Tests

  • 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_group
  • ruff format --check dpgen2/exploration/task/caly_task_group.py tests/exploration/test_make_task_group_from_config.py
  • isort --check-only dpgen2/exploration/task/caly_task_group.py tests/exploration/test_make_task_group_from_config.py
  • git diff --check

Closes #357

Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 23, 2026
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f9d69d5-fc97-4f84-8ddd-3873b00bdbf3

📥 Commits

Reviewing files that changed from the base of the PR and between 6b01f29 and 3a037c0.

📒 Files selected for processing (2)
  • dpgen2/exploration/task/caly_task_group.py
  • tests/exploration/test_make_task_group_from_config.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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
@njzjz-bot
njzjz-bot force-pushed the fix/issue-357-calypso-defaults branch from 262334f to 3a037c0 Compare August 26, 2026 11:00
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.43%. Comparing base (6b01f29) to head (3a037c0).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

wanghan-iapcm

This comment was marked as outdated.

@wanghan-iapcm
wanghan-iapcm dismissed their stale review August 27, 2026 04:12

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 wanghan-iapcm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bare IndexError from the generation loop, where before it reached the assert in caly_input.py that prints the offending values. Such a config was always fatal, so this is message quality only; a numb_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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code scan] Align CALYPSO optional schema with required input generation

2 participants