Skip to content

Stabilize cell volumes for highly skew lattice bases - #137

Open
srijan2607 wants to merge 4 commits into
python-periodictable:masterfrom
srijan2607:fix/stable-skew-cell-volume
Open

srijan2607 wants to merge 4 commits into
python-periodictable:masterfrom
srijan2607:fix/stable-skew-cell-volume

Conversation

@srijan2607

@srijan2607 srijan2607 commented Oct 16, 2026 •

Copy link
Copy Markdown

Evaluate crystal-cell volume using the equivalent four-sine factorization of the Gram determinant. Compensated degree-space sums reduce cancellation for extreme or near-degenerate cell descriptions; this is not a typical reduced-cell density-corruption claim.

Exact orthogonal results are preserved: cell_volume(2) == 8.0 and cell_volume(2, 3, 4) == 24.0. Flat cells with angles (30, 60, 90), (90, 90, 180) and (120, 120, 120) return exactly 0.0. Real-angle conversion occurs before negation so NumPy unsigned scalars do not wrap.

Verification

The configured default command, python -m pytest, passes 279 tests, including the project's doctests, coverage and mypy checks. Mypy reports no issues in 33 source files; overall coverage is 87%, with periodictable/util.py at 100%. This was rerun on Python 3.13.13, NumPy 2.5.4 and mypy 2.4.0.

The previous head produced 2 failed, 277 passed, with three typing errors in REAL_ANGLE_CASES. The follow-up changes only test-constructor annotations; production code, test configuration and checks are unchanged. Hosted CI has passed: all four test jobs and the wheel build completed successfully; the PyPI upload job was skipped.

No new angle-range validation or general length-product overflow guarantee is added. Known behavior outside the principal angle domain remains outside this repair.

Research basis: NIST DLMF §4.21 supplies the addition/product identities; the IUCr coreCIF cell-volume definition supplies the Gram determinant. Floating-point accuracy is tested separately from the algebraic identity.

@srijan2607

Copy link
Copy Markdown
Author

The test-typing follow-up is pushed at 0dbbf7d0a4d2. The configured local python -m pytest run passes 279 tests, including the mypy checks.

@pkienzle could you approve the pending fork workflow when appropriate? The current-head run is waiting for approval with zero jobs executed; hosted CI is not yet verified.

@srijan2607
srijan2607 marked this pull request as ready for review October 18, 2026 04:26

This branch has not been deployed

No deployments
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.

1 participant