Repository navigation
Tolerate determinant roundoff for unimodular unit cells - #245
Open
davrens101 wants to merge 3 commits into
Open
davrens101 wants to merge 3 commits into
davrens101 wants to merge 3 commits into
Conversation
Author
|
CI currently stops during runner preparation, before checkout or tests: GitHub rejects the workflow's retired |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Model.change_unit_cellchecks the determinant of an already-validated integer lattice transformation using exact floating-point equality.scipy.linalg.detuses a floating-point factorization, so valid determinant-one integer changes of basis can be rejected.For example, this matrix has exact integer determinant 1:
In the executed environment,
scipy.linalg.det(U)returns1.0000000000000042. Before the fix, changing a model to this basis raises:Change
After the existing integer-compatibility validation and rounding, compare the determinant against 1 with an explicit small absolute tolerance (
rtol=0,atol=1e-8). Compute the determinant once and reuse it in the error message. Keep the determinant +1/orientation-preserving restriction; do not round arbitrary determinants to the nearest accepted value.Add a deterministic dense/sparse regression, covering Cartesian and reduced cell specifications, that verifies both reciprocal-coordinate band invariance and an inverse-transformation roundtrip. Include an unreleased changelog entry.
This is independent of the lower-dimensional default-origin fix in #244.
Executed validation
Python 3.11.18, NumPy 1.26.4, SciPy 1.17.1 on Windows.
pytest tests/test_change_unit_cell.py tests/test_folding.py tests/test_equivalent_operations.py tests/test_supercell.py -q: 252 passed.NamedTemporaryFilefail withPermissionError, and four CLI tests use Click's removedmix_stderrargument. These paths were not modified or suppressed; no all-green full-suite claim is made.This contribution was prepared with AI assistance. The before/after reproductions, physical band-invariance smoke, and test commands above were executed.
GitHub CI
The original setup failure from retired cache/artifact actions is resolved. Both the generated workflow and its source template now use supported action versions.
Latest head
efa8a2408dacd6ddff8f21512bfd4e65f511f1bf: all seven checks passed, including documentation, pre-commit, the Python test matrix, and version consistency.