swagnercarena / paltas

Conduct simulation-based inference on strong gravitational lensing systems.
MIT License
13 stars 12 forks source link

Images double in size following mag_cut failure #41

Closed JelleAalbers closed 1 year ago

JelleAalbers commented 1 year ago

This fixes a bug introduced in #36: when generating images with drizzle and a magnification cut, the size of all future generated images doubles (along both axes) whenever one image fails the magnification cut.

This is because draw_drizzle monkeys around with ConfigHandler's stateful attributes, but it is terminated by a custom exception before it cleans up the evidence of its dastardly work.

This PR fixes the bug by catching the exception in _draw_image_drizzle, cleaning up the affected properties, then reraising it.

In the future, we might want to

coveralls commented 1 year ago

Coverage Status

Coverage increased (+0.01%) to 95.056% when pulling ee3c045b5eb6f621a1dd36270288a483408dd750 on fix_mag_cut into 2edd7f418a63273d5b2fcc75819e811bceb1f149 on main.

swagnercarena commented 1 year ago

This a great catch, and the change looks good. Long term I agree we want to refactor how the drizzling is being done right now / how the config is treated.