Fix path_length silently ignored in CalculateImageStats#393
Open
animmosmith wants to merge 1 commit into
Open
Conversation
data['settings']['general'] is a plain dict, so
getattr(general, 'path_length', 40) always returned the default,
silently ignoring any path_length configured in config.toml when
calculating volume concentration (vc) and sample_volume. Every
existing test happened to use path_length=40, masking the bug.
Use general.get('path_length', 40) instead, and add a regression
test with a non-default path_length to catch this in future.
Fixes #363
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.
Summary
CalculateImageStats.__call__read the configuredpath_lengthviagetattr(data['settings']['general'], 'path_length', 40). Sincedata['settings']['general']is a plaindict,getattrnever finds the key (dicts don't expose their contents as attributes), so this always silently returned the default40regardless of what was configured inconfig.toml. This affects the volume concentration (vc) andsample_volumeoutputs.path_length=40.0, so the bug produced no test failures.general.get('path_length', 40)), consistent with howPerClassConcentrationalready reads it.path_length(123.0) that fails against the old code and passes against the fix.This closes out #363, which asked for
imx/imy(CCD pixel dimensions) to be propagated intonc_vc_from_stats— that part was already fixed by #369 for the related/duplicate issue #366, which derivesimx/imyfrom the actual raw image shape rather than threading them through config. This PR fixes thepath_lengthregression that #369 introduced along the way.Test plan
pytest pyopia/tests/test_pipeline.pypasses (4 passed)flake8shows no new issues