Skip to content

Feature/unit tests#167

Merged
Jammy2211 merged 145 commits intomainfrom
feature/unit_tests
Apr 9, 2025
Merged

Feature/unit tests#167
Jammy2211 merged 145 commits intomainfrom
feature/unit_tests

Conversation

@Jammy2211
Copy link
Owner

Doing whatever is possible to make unit tests pass, only modules remaining are interferometry and inversion which require dedicated care in their own PR.

Jammy2211 and others added 30 commits April 29, 2024 19:41
These changes allow the PSF convolution to be calculated in a JAX friendly way that works with `jax.grad`.  The method will take `image` and `blurring_image`, convert them from their 1D slim versions back into their 2D naive arrays (with masked points set to zero) and use `jax.scipy.signal.convolve` to do the convolution.

A new keyword has been added to the function `jax_method` that can be either `direct` or `fft` to control how the convolution is done in JAX.  Typically if the PSF kernel is more than about 5x5 the FFT method will be faster.  Because of this `fft` is the default.

Note: with the FFT some more speed might be gained by pre-caching the FFT of the PSF kernel as that is fixed and does not need to be re-computed every time, but this is an optimization that can be put in place at a later time once we know the current function works as expected.
Jax needs the base arrays passed in to work.
These files are all used by the Sersic profile's MGE deflection angles.  This wholesale replacement of numpy for jax.numpy solves many of the issues around the array wrappers (e.g. "Grid2d").  The `numpy_wrapper` is just a simple file that can be imported to provide the correct `np` and an optional `use_jax` bool in case further `if` blocks are needed.

Thankfully, with the full replacement much of the control flow `if` blocks seem to work without modification!
Adjust numpy to jax.numpy imports for files used for the MGE Sersic
@Jammy2211 Jammy2211 requested review from CKrawczyk and rhayes777 April 4, 2025 15:10
@Jammy2211 Jammy2211 merged commit 5de1760 into main Apr 9, 2025
0 of 8 checks passed
@rhayes777 rhayes777 deleted the feature/unit_tests branch April 9, 2025 08:34
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.

4 participants