From 3d108ab076100029dd076c0e8383a3d981964caf Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 7 Feb 2026 17:22:34 +0000 Subject: [PATCH 1/2] update to use mixed preicison option --- autogalaxy/galaxy/to_inversion.py | 2 ++ autogalaxy/profiles/light/linear/abstract.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/autogalaxy/galaxy/to_inversion.py b/autogalaxy/galaxy/to_inversion.py index 50bb95778..82a0087c7 100644 --- a/autogalaxy/galaxy/to_inversion.py +++ b/autogalaxy/galaxy/to_inversion.py @@ -323,6 +323,7 @@ def cls_light_profile_func_list_galaxy_dict_from( psf=self.dataset.psf, light_profile_list=light_profile_list, regularization=light_profile.regularization, + settings=self.settings_inversion, xp=self._xp, ) @@ -486,6 +487,7 @@ def mapper_from( return mapper_from( mapper_grids=mapper_grids, regularization=regularization, + settings=self.settings_inversion, preloads=self.preloads, xp=self._xp, ) diff --git a/autogalaxy/profiles/light/linear/abstract.py b/autogalaxy/profiles/light/linear/abstract.py index a8b9f97f0..d521b1a33 100644 --- a/autogalaxy/profiles/light/linear/abstract.py +++ b/autogalaxy/profiles/light/linear/abstract.py @@ -145,6 +145,7 @@ def __init__( psf: Optional[aa.Kernel2D], light_profile_list: List[LightProfileLinear], regularization=Optional[aa.reg.Regularization], + settings=aa.SettingsInversion(), xp=np, ): """ @@ -202,7 +203,7 @@ def __init__( """ ) - super().__init__(grid=grid, regularization=regularization, xp=xp) + super().__init__(grid=grid, regularization=regularization, settings=settings, xp=xp) self.blurring_grid = blurring_grid self.psf = psf @@ -303,7 +304,10 @@ def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: ) blurred_image_2d = self.psf.convolved_image_from( - image=image_2d, blurring_image=blurring_image_2d, xp=self._xp + image=image_2d, + blurring_image=blurring_image_2d, + use_mixed_precision=self.settings.use_mixed_precision, + xp=self._xp ) blurred_image_2d_list.append(blurred_image_2d.array) From 2a1d9638dd9e177cc26dd9b332d05883bfae9685 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 8 Feb 2026 08:58:21 +0000 Subject: [PATCH 2/2] finish --- autogalaxy/abstract_fit.py | 4 +- autogalaxy/analysis/chaining_util.py | 1 - autogalaxy/profiles/basis.py | 5 ++- autogalaxy/profiles/light/linear/abstract.py | 6 ++- autogalaxy/profiles/mass/stellar/gaussian.py | 42 +++++++++++++------- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/autogalaxy/abstract_fit.py b/autogalaxy/abstract_fit.py index fe5b5f45e..d0581f41a 100644 --- a/autogalaxy/abstract_fit.py +++ b/autogalaxy/abstract_fit.py @@ -110,7 +110,9 @@ def linear_light_profile_intensity_dict( reconstruction = self.inversion.reconstruction_dict[linear_obj_func] for i, light_profile in enumerate(linear_obj_func.light_profile_list): - linear_light_profile_intensity_dict[light_profile] = float(reconstruction[i]) + linear_light_profile_intensity_dict[light_profile] = float( + reconstruction[i] + ) return linear_light_profile_intensity_dict diff --git a/autogalaxy/analysis/chaining_util.py b/autogalaxy/analysis/chaining_util.py index ab3581e1d..a4a82ed16 100644 --- a/autogalaxy/analysis/chaining_util.py +++ b/autogalaxy/analysis/chaining_util.py @@ -500,7 +500,6 @@ def mass_light_dark_basis_from( lmp_model.centre = light_profile.centre lmp_model.ell_comps = light_profile.ell_comps - print(light_profile.intensity) print(type(light_profile.intensity)) diff --git a/autogalaxy/profiles/basis.py b/autogalaxy/profiles/basis.py index 8458179a1..71ece9439 100644 --- a/autogalaxy/profiles/basis.py +++ b/autogalaxy/profiles/basis.py @@ -215,7 +215,10 @@ def deflections_yx_2d_from( """ if len(self.mass_profile_list) > 0: return sum( - [mass.deflections_yx_2d_from(grid=grid, xp=xp) for mass in self.profile_list] + [ + mass.deflections_yx_2d_from(grid=grid, xp=xp) + for mass in self.profile_list + ] ) return xp.zeros((grid.shape[0], 2)) diff --git a/autogalaxy/profiles/light/linear/abstract.py b/autogalaxy/profiles/light/linear/abstract.py index d521b1a33..5bb3f4c01 100644 --- a/autogalaxy/profiles/light/linear/abstract.py +++ b/autogalaxy/profiles/light/linear/abstract.py @@ -203,7 +203,9 @@ def __init__( """ ) - super().__init__(grid=grid, regularization=regularization, settings=settings, xp=xp) + super().__init__( + grid=grid, regularization=regularization, settings=settings, xp=xp + ) self.blurring_grid = blurring_grid self.psf = psf @@ -307,7 +309,7 @@ def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: image=image_2d, blurring_image=blurring_image_2d, use_mixed_precision=self.settings.use_mixed_precision, - xp=self._xp + xp=self._xp, ) blurred_image_2d_list.append(blurred_image_2d.array) diff --git a/autogalaxy/profiles/mass/stellar/gaussian.py b/autogalaxy/profiles/mass/stellar/gaussian.py index 4e06c57f2..1c2f681f9 100644 --- a/autogalaxy/profiles/mass/stellar/gaussian.py +++ b/autogalaxy/profiles/mass/stellar/gaussian.py @@ -197,8 +197,10 @@ def zeta_from(self, grid: aa.type.Grid2DLike, xp=np): ind_pos_y = y >= 0 - scale = q / (xp.asarray(self.sigma, dtype=xp.float64) - * xp.sqrt(xp.asarray(2.0, dtype=xp.float64) * (1.0 - q2))) + scale = q / ( + xp.asarray(self.sigma, dtype=xp.float64) + * xp.sqrt(xp.asarray(2.0, dtype=xp.float64) * (1.0 - q2)) + ) xs = x * scale ys = xp.abs(y) * scale @@ -206,10 +208,7 @@ def zeta_from(self, grid: aa.type.Grid2DLike, xp=np): z1 = xs + 1j * ys z2 = q * xs + 1j * ys / q - exp_term = xp.exp( - -(xs * xs) * (1.0 - q2) - - (ys * ys) * (1.0 / q2 - 1.0) - ) + exp_term = xp.exp(-(xs * xs) * (1.0 - q2) - (ys * ys) * (1.0 / q2 - 1.0)) core = -1j * (self.wofz(z1, xp=xp) - exp_term * self.wofz(z2, xp=xp)) @@ -243,10 +242,13 @@ def wofz(self, z, xp=np): w_large = 1j * inv_sqrt_pi / t # ---------- Region 5 ---------- - U5 = xp.asarray([1.320522, 35.7668, 219.031, - 1540.787, 3321.990, 36183.31], dtype=xp.float64) - V5 = xp.asarray([1.841439, 61.57037, 364.2191, - 2186.181, 9022.228, 24322.84, 32066.6], dtype=xp.float64) + U5 = xp.asarray( + [1.320522, 35.7668, 219.031, 1540.787, 3321.990, 36183.31], dtype=xp.float64 + ) + V5 = xp.asarray( + [1.841439, 61.57037, 364.2191, 2186.181, 9022.228, 24322.84, 32066.6], + dtype=xp.float64, + ) t = inv_sqrt_pi for u in U5: @@ -259,10 +261,22 @@ def wofz(self, z, xp=np): w5 = xp.exp(-z2) + 1j * z * t / s # ---------- Region 6 ---------- - U6 = xp.asarray([5.9126262, 30.180142, 93.15558, - 181.92853, 214.38239, 122.60793], dtype=xp.float64) - V6 = xp.asarray([10.479857, 53.992907, 170.35400, - 348.70392, 457.33448, 352.73063, 122.60793], dtype=xp.float64) + U6 = xp.asarray( + [5.9126262, 30.180142, 93.15558, 181.92853, 214.38239, 122.60793], + dtype=xp.float64, + ) + V6 = xp.asarray( + [ + 10.479857, + 53.992907, + 170.35400, + 348.70392, + 457.33448, + 352.73063, + 122.60793, + ], + dtype=xp.float64, + ) t = inv_sqrt_pi for u in U6: