Skip to content

Stop periodic systems from crashing System construction - #50

Merged
galjos merged 1 commit into
mainfrom
fix-periodic-system-crash
Jun 25, 2026
Merged

Stop periodic systems from crashing System construction#50
galjos merged 1 commit into
mainfrom
fix-periodic-system-crash

Conversation

@galjos

@galjos galjos commented Jun 25, 2026

Copy link
Copy Markdown
Member

Closes #48.

System.__init__ accepts cell: Cell | np.ndarray | None but passed the value straight to spacegroup_number/spacegroup, which are beartype-hinted cell: Cell. Since read_xyz/read_gen return raw ndarrays for periodic input (and beartype_this_package is active), every non-vacuum system aborted construction with BeartypeCallHintParamViolation — the package was effectively vacuum-only, and the repo's own periodic fixture tests/data/thermo/geo_opt.gen could not be run.

Fix

  • Compute the spacegroup only when the cell is an actual Cell; otherwise degrade to spacegroup=None. The cell/spacegroup is unused by the gas-phase RRHO calculation, so periodic input now constructs cleanly instead of crashing.
  • Fix the spacegroup_number property, which returned _spacegroup (the symbol string) instead of _spacegroup_number.

Tests

  • A periodic System built from a raw ndarray cell now constructs and reports spacegroup_number/spacegroup as None (previously raised).
  • A property test pins spacegroup_number/spacegroup to their respective attributes.

141 passed, 0 skipped (suite run with the DFTB+ binaries enabled); pylint 7.94/10.

System.__init__ accepts cell as Cell|ndarray|None but passed it straight to
spacegroup_number/spacegroup, which are beartype-hinted cell: Cell. read_xyz and
read_gen return raw ndarrays for periodic input, so with beartype active every
non-vacuum system aborted construction. Compute the spacegroup only when the cell
is an actual Cell and otherwise degrade to None, since the spacegroup is unused by
the gas-phase RRHO calculation. Also fix the spacegroup_number property, which
returned _spacegroup instead of _spacegroup_number.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.80%. Comparing base (9a490af) to head (862f24d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #50      +/-   ##
==========================================
+ Coverage   93.63%   93.80%   +0.16%     
==========================================
  Files          21       21              
  Lines        1194     1194              
==========================================
+ Hits         1118     1120       +2     
+ Misses         76       74       -2     
Flag Coverage Δ
unittests 93.80% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@galjos
galjos merged commit 0d93878 into main Jun 25, 2026
3 checks passed
@galjos
galjos deleted the fix-periodic-system-crash branch June 25, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Periodic systems crash in System.__init__ (beartype hint mismatch)

1 participant