perform fix by not linking state blurring grid to dataset grid#221
Merged
perform fix by not linking state blurring grid to dataset grid#221
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses multiple robustness and correctness issues across autoarray, focused on mask-derived blurring grids, PSF/convolution normalization behavior, and safer plotting defaults.
Changes:
- Update
GridsDataset.blurringto derive the blurring mask from the dataset mask + PSF kernel shape (instead of relying on PSF state). - Adjust
Convolver.normalizedtyping/behavior and remove the “force odd FFT shape” padding logic. - Make
DelaunayDrawer.draw_delaunay_pixelsresilient topixel_values=Noneby plotting zeros.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| autoarray/plot/wrap/two_d/delaunay_drawer.py | Avoids plotting errors by defaulting pixel_values to zeros when None. |
| autoarray/operators/convolver.py | Removes odd-shape FFT padding tweak; updates normalized API typing/intent. |
| autoarray/dataset/grids.py | Fixes blurring grid mask derivation to be dataset-mask-driven, not PSF-state-driven. |
Comments suppressed due to low confidence (3)
autoarray/plot/wrap/two_d/delaunay_drawer.py:67
- This change introduces a new behavior where
pixel_values=Noneis plotted as zeros instead of raising. There is an existing test suite forDelaunayDrawer, but it does not cover theNonepath; adding a regression test (includinguse_log10=True) would help ensure plotting stays robust.
if pixel_values is None:
pixel_values = np.zeros(shape=mapper.source_plane_mesh_grid.shape[0])
pixel_values = np.asarray(pixel_values)
autoarray/dataset/grids.py:110
GridsDataset.blurringnow derives the blurring mask fromself.mask, which changes behavior versus using the PSF state. There are dataset-related tests, but none appear to assert the correctness ofgrids.blurring; please add a regression test that verifies the derived blurring grid/mask matchesmask.derive_mask.blurring_from(kernel_shape_native=psf.kernel.shape_native)for a representative mask + PSF.
blurring_mask = self.mask.derive_mask.blurring_from(
kernel_shape_native=self.psf.kernel.shape_native
)
self._blurring = Grid2D.from_mask(
mask=blurring_mask,
over_sample_size=1,
)
autoarray/operators/convolver.py:124
- The
ConvolverStatedocstring still states that evenfft_shapesizes are incremented to odd sizes as a workaround, but that adjustment has been removed from the implementation here. Please update the docstring to match the new behavior (or reintroduce the adjustment if it is still required).
full_shape = tuple(
s1 + s2 - 1 for s1, s2 in zip(mask_shape, self.kernel.shape_native)
)
fft_shape = tuple(scipy.fft.next_fast_len(s, real=True) for s in full_shape)
self.fft_shape = fft_shape
self.mask = mask.resized_from(self.fft_shape, pad_value=1)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and bug fixes across the
autoarraypackage, focusing on mask handling, convolution normalization, and plotting robustness. The most important changes include correcting mask derivation for blurring, updating normalization behavior for theConvolver, and improving error handling in plotting routines.Mask Handling Improvements:
autoarray/dataset/grids.pyby generating the mask usingself.mask.derive_mask.blurring_from()instead of relying on the PSF state, ensuring more accurate blurring grid construction.Convolver and Kernel Normalization:
normalizedproperty inautoarray/operators/convolver.pyto return a normalizedConvolverinstance instead of aKernel2D, aligning the normalization behavior with the intended class.Plotting Robustness:
draw_delaunay_pixelsinautoarray/plot/wrap/two_d/delaunay_drawer.pyto handle cases wherepixel_valuesisNoneby defaulting to a zero array, preventing plotting errors.Code Cleanup:
autoarray/operators/convolver.pyfor better code clarity and maintainability.Padding and FFT Shape Logic:
autoarray/operators/convolver.py, addressing padding and wrap-around artifact concerns for more consistent convolution behavior.