fix: validate box lengths and angles on Cell construction - #215
Open
galjos wants to merge 1 commit into
Open
Conversation
Cell built its box matrix without any validation, so a zero-length box escaped as a raw numpy.linalg.LinAlgError from the inverse-matrix setter, far from the offending input, and geometrically impossible angle triples produced a NaN box matrix that silently corrupted volumes, imaging and downstream analysis output. setup_box_matrix now rejects non-positive box lengths, angles outside (0, 180) degrees and angle triples whose box-matrix radicand is not positive, raising a new CellError that names the offending values. Valid cells, including the vacuum cell, are unaffected.
Contributor
|
PYLINT REPORT Your code has been rated at 9.78/10 Full reportRaw metrics
Duplication
Messages by category
% errors / warnings by module
Messages
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #215 +/- ##
=======================================
Coverage 93.94% 93.95%
=======================================
Files 177 177
Lines 9227 9241 +14
=======================================
+ Hits 8668 8682 +14
Misses 559 559
🚀 New features to boost your workflow:
|
97gamjak
approved these changes
Aug 26, 2026
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.
A zero-length box surfaced as a raw LinAlgError from whatever code first inverted the matrix, and angle combinations that cannot close a parallelepiped were accepted and turned every downstream value into NaN without a word.
setup_box_matrixnow validates lengths, the angle range, and the closure condition, raising a newCellError; the setters go through the same path. Valid cells, including the vacuum cell, are byte-for-byte unchanged.Four regression tests added.
Fixes #214.