From 3e337917d540cc23341dca478ab9aa2952ae4b6f Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 20 Dec 2023 12:49:27 +0000 Subject: [PATCH] default relocate_pix_border value now comes from config --- autoarray/config/general.yaml | 1 + autoarray/inversion/inversion/settings.py | 12 ++++++++++-- .../pixelization/mesh/test_triangulation.py | 3 +-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/autoarray/config/general.yaml b/autoarray/config/general.yaml index 7beab815c..c10fe8019 100644 --- a/autoarray/config/general.yaml +++ b/autoarray/config/general.yaml @@ -3,6 +3,7 @@ inversion: 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. no_regularization_add_to_curvature_diag_value : 1.0e-3 # The default value added to the curvature matrix's diagonal when regularization is not applied to a linear object, which prevents inversion's failing due to the matrix being singular. positive_only_uses_p_initial: true # If True, the positive-only solver of an inversion's uses an initial guess of the reconstructed data's values as which values should be positive, speeding up the solver. + relocate_pix_border: false # If True, by default a pixelization's border is used to relocate all pixels outside its border to the border. reconstruction_vmax_factor: 0.5 # Plots of an Inversion's reconstruction use the reconstructed data's bright value multiplied by this factor. numba: use_numba: true diff --git a/autoarray/inversion/inversion/settings.py b/autoarray/inversion/inversion/settings.py index e62935593..bdd19dfa1 100644 --- a/autoarray/inversion/inversion/settings.py +++ b/autoarray/inversion/inversion/settings.py @@ -13,7 +13,7 @@ def __init__( use_w_tilde: bool = True, use_positive_only_solver: Optional[bool] = None, positive_only_uses_p_initial: Optional[bool] = None, - relocate_pix_border : bool = True, + relocate_pix_border : Optional[bool] = None, force_edge_pixels_to_zeros: bool = True, force_edge_image_pixels_to_zeros: bool = False, image_pixels_source_zero=None, @@ -64,7 +64,7 @@ def __init__( self.use_w_tilde = use_w_tilde self._use_positive_only_solver = use_positive_only_solver self._positive_only_uses_p_initial = positive_only_uses_p_initial - self.relocate_pix_border = relocate_pix_border + self._relocate_pix_border = relocate_pix_border self.use_linear_operators = use_linear_operators self.force_edge_pixels_to_zeros = force_edge_pixels_to_zeros self.force_edge_image_pixels_to_zeros = force_edge_image_pixels_to_zeros @@ -91,6 +91,14 @@ def positive_only_uses_p_initial(self): return self._positive_only_uses_p_initial + @property + def relocate_pix_border(self): + + if self._relocate_pix_border is None: + return conf.instance["general"]["inversion"]["relocate_pix_border"] + + return self._relocate_pix_border + @property def no_regularization_add_to_curvature_diag_value(self): if self._no_regularization_add_to_curvature_diag_value is None: diff --git a/test_autoarray/inversion/pixelization/mesh/test_triangulation.py b/test_autoarray/inversion/pixelization/mesh/test_triangulation.py index e5f2f681d..999fa4e85 100644 --- a/test_autoarray/inversion/pixelization/mesh/test_triangulation.py +++ b/test_autoarray/inversion/pixelization/mesh/test_triangulation.py @@ -1,7 +1,6 @@ -import autoarray as aa -import numpy as np import pytest +import autoarray as aa def test___preloads_used_for_relocated_grid(sub_grid_2d_7x7): mesh = aa.mesh.Delaunay()