Feature/mask 1d util to numpy#164
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors several numba‑based functions to use numpy operations and removes deprecated mask methods to pave the way for JAX integration. Key changes include replacing custom total pixel calculations with np.sum(~mask), removal of obsolete mask functions in test and production code, and minor formatting and documentation updates.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test_autoarray/mask/test_mask_2d_util.py | Renamed and adjusted tests; removed obsolete tests and added a debug print in one test. |
| test_autoarray/mask/test_mask_2d.py | Removed tests for circular anti‑annular mask functionality. |
| autoarray/structures/vectors/uniform.py | Minor formatting change in the magnitudes method. |
| autoarray/structures/grids/grid_2d_util.py | Replaced call to total_pixels function with np.sum(~mask_2d) and reformatted grid calculation. |
| autoarray/structures/arrays/array_2d_util.py | Updated usage of total_pixels in array functions and adjusted formatting in lambda calls. |
| autoarray/plot/multi_plotters.py | Added new function output_to_fits and updated documentation. |
| autoarray/operators/over_sampling/over_sampler.py | Minor formatting changes. |
| autoarray/operators/over_sampling/over_sample_util.py | Replaced total_pixels call with np.sum(~mask_2d). |
| autoarray/operators/contour.py | Reformatted the call to find_contours for better readability. |
| autoarray/mask/mask_2d.py | Removed the circular_anti_annular class method. |
| autoarray/mask/abstract_mask.py | Minor formatting update. |
| autoarray/inversion/pixelization/mesh/mesh_util.py | Formatted function signature for clarity. |
| autoarray/inversion/pixelization/border_relocator.py | Replaced total_pixels calculation with np.sum(~mask_2d). |
| autoarray/geometry/geometry_util.py | Adjusted formatting and ensured consistent arithmetic operations. |
Comments suppressed due to low confidence (1)
test_autoarray/mask/test_mask_2d_util.py:742
- [nitpick] Consider removing or conditionally disabling the debug print statement to avoid polluting test output.
print(edge_pixels)
| filenane | ||
| The filename that the .fits file is output to. |
There was a problem hiding this comment.
The term 'filenane' appears to be a typo. Change it to 'filename'.
| filenane | |
| The filename that the .fits file is output to. | |
| filename | |
| The filename that the .fits file is output to. |
CKrawczyk
left a comment
There was a problem hiding this comment.
Only one potential jax think jumped out at me, otherwise it all looks reasonable.
| """ | ||
| if use_jax: | ||
| return (~mask_2d.astype(bool)).sum() | ||
| return jnp.stack(jnp.nonzero(~mask_2d.astype(bool))).T |
There was a problem hiding this comment.
I will point out that this will not jit as the size keyword is not provided as a static value. This is fine as long as we make sure this function will not be called inside likelihood functions.
Refactoring of numba-based for loops to numpy functions, on my quest to remove all numba to ease JAX implementation.
This refactors the solitary function in
mask_1d_util.py