refactor: split fit tests into granular focused tests#230
Merged
Conversation
Split each monolithic test function into individual focused tests, one per property or behaviour being verified. Tests now fail with precise names that identify exactly which quantity is wrong (e.g. chi_squared, residual_map, log_evidence) rather than a single large function covering a dozen assertions. Changes per file: - test_fit_imaging.py: 3 tests → 21 tests; helper builders extracted to avoid repetition; dirty-image block was left as fixture-based tests - test_fit_interferometer.py: 4 tests → 27 tests; dirty quantities split into one test per map type - test_fit_dataset.py: 3 tests → 6 tests; figure_of_merit split by inversion regularization branch; chi_squared covariance tests separated - test_fit_util.py: 12 tests → 30 tests; each util function now has one test per scenario; parametrize not needed as inputs differ meaningfully Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
test_fit_imaging.py: 3 monolithic tests → 21 focused tests. Each fit quantity (mask, data, noise_map, signal_to_noise_map, residual_map, normalized_residual_map, chi_squared_map, chi_squared, reduced_chi_squared, noise_normalization, log_likelihood, log_evidence, figure_of_merit) now has its own test. Shared setup extracted into private builder helpers to avoid duplication.test_fit_interferometer.py: 4 tests → 27 tests.test__dirty_quantitiessplit into one test per dirty-map type (dirty_image, dirty_noise_map, dirty_signal_to_noise_map, dirty_model_image, dirty_residual_map, dirty_normalized_residual_map, dirty_chi_squared_map).test_fit_dataset.py: 3 tests → 6 tests.figure_of_meritsplit by whether inversion has regularization. Noise-covariance chi-squared and figure-of-merit separated into distinct tests.test_fit_util.py: 12 tests → 30 tests. Every utility function now has one test per scenario (identical model, different model, masked data, 1D vs 2D, varied noise, complex data). No numerical values changed.Test plan
python -m pytest test_autoarray/fit/ -v— all tests should pass🤖 Generated with Claude Code