Repository navigation
Conversation
The allow_missing_positions branch of get_volume_positions compared distances expressed as multiples of the slice spacing, so 'atol', which is documented in mm, accepted a larger physical deviation the wider the spacing, and 'rtol' was relative to a slice's index rather than to the spacing as it is in the regularly-spaced branch. Convert the rounded multiples back to mm and compare there, so both branches read the tolerances the same way and the logged deviation is in the unit it claims.
Collaborator
|
@CedricConday Thanks for catching this and the PR! |
CPBridge
approved these changes
Oct 6, 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.
Fixes #464.
In the
allow_missing_positionsbranch ofget_volume_positions, the deviation of each slice from its nearest integer multiple of the spacing was compared in units of the spacing, soatol(documented in mm) accepted a larger physical error the wider the spacing, andrtolscaled with the slice index rather than with the spacing as it does in the regularly-spaced branch.The branch now converts the rounded multiples back to mm (
round(multiple) * spacing + min), measures the deviation there, and compares it withatol + rtol * |spacing|, which is the same rulenp.isclose(spacings, spacing, rtol, atol)applies in the regular branch. The debug log reports the maximum deviation in mm, as its message says. Nothing changes for callers whose slices sit within tolerance under both readings; positions that were only accepted because the spacing was wide are now rejected, asatoldocuments.Test:
test_get_volume_positions_missing_tolerance_unitschecks that a 0.5 mm displacement is rejected withatol=0.1at 1, 5, 10 and 20 mm spacing, and that a 0.05 mm displacement is accepted at all four.tests/test_spatial.pypasses (128 tests) andflake8is clean on both files; mypy's pre-existing errors inspatial.pyare untouched.