Skip to content

Feature/remove preloads#220

Merged
Jammy2211 merged 8 commits intomainfrom
feature/remove_preloads
Feb 25, 2026
Merged

Feature/remove preloads#220
Jammy2211 merged 8 commits intomainfrom
feature/remove_preloads

Conversation

@Jammy2211
Copy link
Owner

This pull request introduces a new feature for zeroing edge pixels in pixelizations during inversion, improving the physical plausibility of reconstructed solutions. It also removes the Preloads dependency from the inversion and mapper classes, streamlining the codebase. Additionally, test fixtures are updated to explicitly specify pixel counts for meshes, ensuring consistency and clarity.

The most important changes are:

Edge Pixel Zeroing Feature:

  • Added a new configuration option use_edge_zeroed_pixels in general.yaml to enable zeroing of edge pixels in pixelizations, preventing unphysical values in reconstructed solutions at the pixelization boundaries.
  • Implemented logic in AbstractInversion (abstract.py) to compute and use global indices of zeroed pixels, ensuring only non-edge pixels are solved for in the inversion. This includes the new zeroed_ids_to_keep property and updates to the reconstruction logic. [1] [2] [3]

Preloads Removal and Refactoring:

Test Fixture Updates:

  • Updated mesh instantiations in test fixtures to explicitly specify the number of pixels, ensuring clarity and consistency in test setups. [1] [2]

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 pull request introduces a new edge pixel zeroing feature for pixelizations during inversion and removes the Preloads dependency, streamlining the inversion API. The edge zeroing feature prevents unphysical values in reconstructed solutions at pixelization boundaries by excluding edge pixels from the linear solve.

Changes:

  • Introduced use_edge_zeroed_pixels configuration option and implemented the edge pixel zeroing logic in the inversion reconstruction process
  • Completely removed the Preloads class and all its references throughout the codebase, simplifying the inversion API
  • Updated test fixtures to explicitly specify pixel counts for mesh instantiations, improving test clarity

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
autoarray/config/general.yaml Added use_edge_zeroed_pixels configuration option (default: true)
test_autoarray/config/general.yaml Added use_edge_zeroed_pixels configuration option (default: false for tests)
autoarray/settings.py Added use_edge_zeroed_pixels property to Settings class
autoarray/preloads.py Deleted entire file containing Preloads class
autoarray/__init__.py Removed Preloads import
autoarray/inversion/inversion/abstract.py Removed preloads parameter, added zeroed_ids_to_keep cached property, updated reconstruction logic
autoarray/inversion/inversion/imaging/*.py Removed preloads parameter from all imaging inversion classes
autoarray/inversion/inversion/factory.py Removed preloads parameter from factory functions
autoarray/inversion/mappers/abstract.py Removed preloads parameter, added mesh property
autoarray/inversion/mesh/mesh/delaunay.py Added mandatory pixels parameter, zeroed_pixels parameter, and zeroed_pixels property
autoarray/inversion/mesh/mesh/knn.py Added mandatory pixels and zeroed_pixels parameters
autoarray/inversion/mesh/mesh/rectangular_adapt_density.py Added zeroed_pixels property implementation
autoarray/inversion/mesh/mesh/abstract.py Removed preloads parameter from interpolator_from
autoarray/inversion/mesh/interpolator/*.py Removed preloads parameter from all interpolator classes
autoarray/inversion/mesh/mesh_geometry/rectangular.py Removed total_linear_light_profiles parameter from rectangular_edge_pixel_list_from
test_autoarray/inversion/inversion/test_factory.py Updated test to use new settings-based approach instead of preloads
test_autoarray/inversion/inversion/test_abstract.py Updated mesh instantiations to include explicit pixel counts
test_autoarray/inversion/pixelization/*/test_*.py Updated mesh instantiations to include explicit pixel counts
autoarray/fixtures.py Updated fixture mesh instantiations to include explicit pixel counts
Comments suppressed due to low confidence (5)

autoarray/config/general.yaml:7

  • Spelling error: "solutuion" should be "solution".
  use_positive_only_solver: true      # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion.

test_autoarray/config/general.yaml:13

  • Spelling error: "solutuion" should be "solution".
  use_positive_only_solver: false    # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion.

autoarray/inversion/inversion/abstract.py:476

  • Trailing whitespace on this line should be removed.
    autoarray/config/general.yaml:8
  • There is inconsistent spacing in the YAML key. The key use_edge_zeroed_pixels : has a space before the colon, while all other keys in this file do not. For consistency with the rest of the file, it should be use_edge_zeroed_pixels: (without the space before the colon).
  use_edge_zeroed_pixels : true       # If True, the edge pixels of a pixelization are set to zero, which prevents unphysical values in the reconstructed solution at the edge of the pixelization.

test_autoarray/config/general.yaml:14

  • There is inconsistent spacing in the YAML key. The key use_edge_zeroed_pixels : has a space before the colon, while all other keys in this file do not. For consistency with the rest of the file, it should be use_edge_zeroed_pixels: (without the space before the colon).
  use_edge_zeroed_pixels : false       # If True, the edge pixels of a pixelization are set to zero, which prevents unphysical values in the reconstructed solution at the edge of the pixelization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 8 to +23
def __init__(
self,
pixels: int,
k_neighbors=10,
radius_scale=1.5,
areas_factor=0.5,
split_neighbor_division=2,
zeroed_pixels: Optional[int] = 0,
):

self.k_neighbors = k_neighbors
self.radius_scale = radius_scale
self.areas_factor = areas_factor
self.split_neighbor_division = split_neighbor_division

super().__init__()
super().__init__(pixels=pixels, zeroed_pixels=zeroed_pixels)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The __init__ method lacks a docstring. Given that this class now requires a mandatory pixels parameter and has several other configuration parameters (k_neighbors, radius_scale, areas_factor, split_neighbor_division, zeroed_pixels), documentation is essential for users to understand how to properly instantiate and use this class.

Copilot uses AI. Check for mistakes.
Jammy2211 and others added 3 commits February 25, 2026 10:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Jammy2211 Jammy2211 merged commit 7844633 into main Feb 25, 2026
8 checks passed
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.

2 participants