Skip to content

refactor: split fit tests into granular focused tests#230

Merged
Jammy2211 merged 1 commit intomainfrom
feature/refactor-fit-tests
Mar 10, 2026
Merged

refactor: split fit tests into granular focused tests#230
Jammy2211 merged 1 commit intomainfrom
feature/refactor-fit-tests

Conversation

@Jammy2211
Copy link
Owner

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_quantities split 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_merit split 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
  • Verify test names encode condition + expectation so failures are immediately informative

🤖 Generated with Claude Code

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>
@Jammy2211 Jammy2211 merged commit 101304f into main Mar 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant