Skip to content

Feature/mask 1d util to numpy#164

Merged
Jammy2211 merged 17 commits intofeature/jax_wrapperfrom
feature/mask_1d_util_to_numpy
Apr 2, 2025
Merged

Feature/mask 1d util to numpy#164
Jammy2211 merged 17 commits intofeature/jax_wrapperfrom
feature/mask_1d_util_to_numpy

Conversation

@Jammy2211
Copy link
Owner

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +304 to +305
filenane
The filename that the .fits file is output to.
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term 'filenane' appears to be a typo. Change it to 'filename'.

Suggested change
filenane
The filename that the .fits file is output to.
filename
The filename that the .fits file is output to.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@CKrawczyk CKrawczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Jammy2211 Jammy2211 merged commit 3066c77 into feature/jax_wrapper Apr 2, 2025
0 of 16 checks passed
@Jammy2211 Jammy2211 deleted the feature/mask_1d_util_to_numpy branch April 30, 2025 18:13
@Jammy2211 Jammy2211 restored the feature/mask_1d_util_to_numpy branch April 30, 2025 18:14
@Jammy2211 Jammy2211 deleted the feature/mask_1d_util_to_numpy branch June 24, 2025 13:46
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.

3 participants