Skip to content

Commit d7d31f6

Browse files
Jammy2211Jammy2211
authored andcommitted
inversion_util
1 parent e5e1a07 commit d7d31f6

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

autoarray/inversion/inversion/abstract.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ def reconstruction(self) -> np.ndarray:
436436
inversion_util.reconstruction_positive_only_from(
437437
data_vector=data_vector,
438438
curvature_reg_matrix=curvature_reg_matrix,
439-
settings=self.settings,
440439
)
441440
)
442441

@@ -455,15 +454,11 @@ def reconstruction(self) -> np.ndarray:
455454
return inversion_util.reconstruction_positive_only_from(
456455
data_vector=self.data_vector,
457456
curvature_reg_matrix=self.curvature_reg_matrix,
458-
settings=self.settings,
459457
)
460458

461-
mapper_param_range_list = self.param_range_list_from(cls=AbstractMapper)
462-
463459
return inversion_util.reconstruction_positive_negative_from(
464460
data_vector=self.data_vector,
465461
curvature_reg_matrix=self.curvature_reg_matrix,
466-
mapper_param_range_list=mapper_param_range_list,
467462
)
468463

469464
@cached_property

autoarray/inversion/inversion/inversion_util.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,9 @@ def curvature_matrix_with_added_to_diag_from(
5656
curvature_matrix
5757
The curvature matrix which is being constructed in order to solve a linear system of equations.
5858
"""
59-
try:
60-
return curvature_matrix.at[
61-
no_regularization_index_list, no_regularization_index_list
62-
].add(value)
63-
except AttributeError:
64-
return curvature_matrix_with_added_to_diag_from_numba(
65-
curvature_matrix=curvature_matrix,
66-
value=value,
67-
no_regularization_index_list=no_regularization_index_list,
68-
)
59+
return curvature_matrix.at[
60+
no_regularization_index_list, no_regularization_index_list
61+
].add(value)
6962

7063

7164
@numba_util.jit()
@@ -218,8 +211,6 @@ def mapped_reconstructed_data_via_w_tilde_from(
218211
def reconstruction_positive_negative_from(
219212
data_vector: np.ndarray,
220213
curvature_reg_matrix: np.ndarray,
221-
mapper_param_range_list,
222-
force_check_reconstruction: bool = False,
223214
):
224215
"""
225216
Solve the linear system [F + reg_coeff*H] S = D -> S = [F + reg_coeff*H]^-1 D given by equation (12)
@@ -262,7 +253,6 @@ def reconstruction_positive_negative_from(
262253
def reconstruction_positive_only_from(
263254
data_vector: np.ndarray,
264255
curvature_reg_matrix: np.ndarray,
265-
settings: SettingsInversion = SettingsInversion(),
266256
):
267257
"""
268258
Solve the linear system Eq.(2) (in terms of minimizing the quadratic value) of
@@ -308,21 +298,7 @@ def reconstruction_positive_only_from(
308298
"""
309299
import jaxnnls
310300

311-
try:
312-
reconstruction = jaxnnls.solve_nnls_primal(curvature_reg_matrix, data_vector)
313-
except (RuntimeError, np.linalg.LinAlgError, ValueError) as e:
314-
raise exc.InversionException() from e
315-
316-
def handle_nan(reconstruction):
317-
return jnp.zeros_like(reconstruction)
318-
319-
def handle_valid(reconstruction):
320-
return reconstruction
321-
322-
has_nan = jnp.isnan(reconstruction).any()
323-
reconstruction = lax.cond(has_nan, handle_nan, handle_valid, reconstruction)
324-
325-
return reconstruction
301+
return jaxnnls.solve_nnls_primal(curvature_reg_matrix, data_vector)
326302

327303

328304
def preconditioner_matrix_via_mapping_matrix_from(

0 commit comments

Comments
 (0)