Skip to content

Refactoring image deconvolution classes#449

Draft
hiyoneda wants to merge 4 commits intocositools:developfrom
hiyoneda:image_deconvolution_refactoring
Draft

Refactoring image deconvolution classes#449
hiyoneda wants to merge 4 commits intocositools:developfrom
hiyoneda:image_deconvolution_refactoring

Conversation

@hiyoneda
Copy link
Contributor

@hiyoneda hiyoneda commented Jan 7, 2026

This PR improves code maintainability through three key refactorings:

  1. Centralize magic numbers into constants.py

    Added the new filecosipy/image_deconvolution/constants.py and centralized magic numbers and default values

  2. Reduce code duplication in finalization methods

    Added _save_standard_results() method in DeconvolutionAlgorithmBase because the common save logic was used in three classes (RichardsonLucySimple, RichardsonLucy, MAP_RichardsonLucy)

  3. Improved Error Messages
    Files modified: image_deconvolution.py

    • model_initialization(): Shows available model classes
    • register_deconvolution_algorithm(): Shows available algorithms

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.63%. Comparing base (f4511d1) to head (0aa57c2).

Files with missing lines Patch % Lines
cosipy/image_deconvolution/image_deconvolution.py 90.90% 1 Missing ⚠️
Files with missing lines Coverage Δ
cosipy/image_deconvolution/MAP_RichardsonLucy.py 96.35% <100.00%> (+0.05%) ⬆️
cosipy/image_deconvolution/RichardsonLucy.py 95.55% <100.00%> (+0.10%) ⬆️
cosipy/image_deconvolution/RichardsonLucySimple.py 94.18% <100.00%> (+0.13%) ⬆️
cosipy/image_deconvolution/constants.py 100.00% <100.00%> (ø)
.../image_deconvolution/coordsys_conversion_matrix.py 96.66% <100.00%> (+0.03%) ⬆️
cosipy/image_deconvolution/dataIF_COSI_DC2.py 92.17% <100.00%> (+0.06%) ⬆️
cosipy/image_deconvolution/dataIF_Parallel.py 15.59% <100.00%> (+0.45%) ⬆️
...mage_deconvolution/deconvolution_algorithm_base.py 93.98% <100.00%> (+0.23%) ⬆️
...olution/image_deconvolution_data_interface_base.py 100.00% <100.00%> (ø)
cosipy/image_deconvolution/image_deconvolution.py 92.30% <90.90%> (+0.27%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hiyoneda
Copy link
Contributor Author

hiyoneda commented Jan 8, 2026

#259 (comment)

For the future, I think it would be nice if RichardLucySimple were kept, well, simple 😬. That is, with the minimal set of parameters to make it work. You could add an intermediate class e.g. RLAugmented, deriving from RLSimple and adding these extra parameters, and RL and MAP_RL can derive from RLAugmented. Maybe other naming conventions would be better, but you get the point. This doesn't prevent this from being merged, just something for later, as RichardLucySimple can be the landing point for new students.

I will work on this in this PR. So I changed the status to the draft PR till it is finished.

@hiyoneda hiyoneda marked this pull request as draft January 8, 2026 04:43
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