diff --git a/simpeg_drivers/components/models.py b/simpeg_drivers/components/models.py index be91a6f4..0650807e 100644 --- a/simpeg_drivers/components/models.py +++ b/simpeg_drivers/components/models.py @@ -276,9 +276,9 @@ def lower_bound(self) -> np.ndarray | None: bound_model = -self._upper_bound.model if bound_model is None: - return -np.inf - - lbound = bound_model.copy() + lbound = np.full(self.n_active, -np.inf) + else: + lbound = bound_model.copy() if self.is_sigma: is_finite = np.isfinite(lbound) @@ -304,9 +304,9 @@ def upper_bound(self) -> np.ndarray | None: bound_model = self._upper_bound.model if bound_model is None: - return np.inf - - ubound = bound_model.copy() + ubound = np.full(self.n_active, np.inf) + else: + ubound = bound_model.copy() if self.is_sigma: is_finite = np.isfinite(ubound) diff --git a/simpeg_drivers/utils/regularization.py b/simpeg_drivers/utils/regularization.py index 506b30c8..5d06a3ef 100644 --- a/simpeg_drivers/utils/regularization.py +++ b/simpeg_drivers/utils/regularization.py @@ -510,9 +510,13 @@ def set_rotated_operators( ) grad_op_active = mesh.Pac.T @ (unit_grad_op @ mesh.Pac) + + # Remove extra partial volume from missing neighbors + row_sum = np.asarray(grad_op_active.sum(axis=1)).ravel() + grad_op_active -= sdiag(row_sum) + vol_avg_op = mesh.Pac.T @ (vol_avg_op @ mesh.Pac) - active_faces = np.isclose(grad_op_active @ np.ones(mesh.n_cells), 0) - active_faces &= grad_op_active.max(axis=1).toarray().ravel() != 0 + active_faces = grad_op_active.max(axis=1).toarray().ravel() != 0 vol_avg_op = vol_avg_op[active_faces, :] vol_avg_op = sdiag(np.asarray(vol_avg_op.sum(axis=1)).ravel() ** -1) @ vol_avg_op diff --git a/tests/run_tests/driver_2d_rotated_gradients_test.py b/tests/run_tests/driver_2d_rotated_gradients_test.py index 582f6132..5d6be39f 100644 --- a/tests/run_tests/driver_2d_rotated_gradients_test.py +++ b/tests/run_tests/driver_2d_rotated_gradients_test.py @@ -42,7 +42,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 0.6464643069717512, "phi_d": 1160, "phi_m": 5.29} +target_run = {"data_norm": 0.6464643069717512, "phi_d": 1150, "phi_m": 5.37} def test_dc2d_rotated_grad_fwr_run( @@ -52,7 +52,7 @@ def test_dc2d_rotated_grad_fwr_run( refinement=(4, 6), ): filepath = Path(tmp_path) / "inversion_test.ui.geoh5" - with Workspace.create(filepath) as geoh5: + with get_workspace(filepath) as geoh5: # Run the forward components = SyntheticsComponents( geoh5=geoh5, diff --git a/tests/run_tests/driver_dc_b2d_rotated_gradients_test.py b/tests/run_tests/driver_dc_b2d_rotated_gradients_test.py index 203f437e..96d53142 100644 --- a/tests/run_tests/driver_dc_b2d_rotated_gradients_test.py +++ b/tests/run_tests/driver_dc_b2d_rotated_gradients_test.py @@ -49,7 +49,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 1.1060093911270892, "phi_d": 208, "phi_m": 0.468} +target_run = {"data_norm": 1.1060093911270892, "phi_d": 209, "phi_m": 0.468} def test_dc_rotated_p3d_fwr_run( diff --git a/tests/run_tests/driver_grav_test.py b/tests/run_tests/driver_grav_test.py index 3dc48539..67309a32 100644 --- a/tests/run_tests/driver_grav_test.py +++ b/tests/run_tests/driver_grav_test.py @@ -37,6 +37,8 @@ from tests.utils.targets import check_target, get_inversion_output, get_workspace +# pylint: disable=no-member + # To test the full run and validate the inversion. # Move this file out of the test directory and run. target_run = {"data_norm": 0.0028055270497087128, "phi_d": 8.24e-06, "phi_m": 0.0234} @@ -161,7 +163,7 @@ def test_gravity_run( driver = GravityInversionDriver.start(str(tmp_path / "Inv_run.ui.json")) assert driver.params.data_object.uid != gz.parent.uid - assert driver.models.upper_bound is np.inf + assert np.all(np.isinf(driver.models.upper_bound)) with Workspace(driver.params.geoh5.h5file) as run_ws: output = get_inversion_output( diff --git a/tests/run_tests/driver_joint_pgi_homogeneous_test.py b/tests/run_tests/driver_joint_pgi_homogeneous_test.py index 43a7cc8b..aff3e37d 100644 --- a/tests/run_tests/driver_joint_pgi_homogeneous_test.py +++ b/tests/run_tests/driver_joint_pgi_homogeneous_test.py @@ -54,7 +54,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 390.70695894864303, "phi_d": 2020, "phi_m": 8.98} +target_run = {"data_norm": 390.70695894864303, "phi_d": 2030, "phi_m": 9.23} INDUCING_FIELD = (50000.0, 90.0, 0.0) diff --git a/tests/run_tests/driver_mvi_test.py b/tests/run_tests/driver_mvi_test.py index b76caa91..35b01546 100644 --- a/tests/run_tests/driver_mvi_test.py +++ b/tests/run_tests/driver_mvi_test.py @@ -45,7 +45,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_mvi_run = {"data_norm": 149.10117434016038, "phi_d": 1070, "phi_m": 0.129} +target_mvi_run = {"data_norm": 149.10117434016038, "phi_d": 1040, "phi_m": 0.129} def test_magnetic_vector_fwr_run( diff --git a/tests/run_tests/driver_rotated_gradients_test.py b/tests/run_tests/driver_rotated_gradients_test.py index be4f32a2..145372e2 100644 --- a/tests/run_tests/driver_rotated_gradients_test.py +++ b/tests/run_tests/driver_rotated_gradients_test.py @@ -40,8 +40,9 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. +# pylint: disable=no-member -target_run = {"data_norm": 0.4076195420139727, "phi_d": 37.5, "phi_m": 427} +target_run = {"data_norm": 0.4076195420139727, "phi_d": 35.5, "phi_m": 432} def test_gravity_rotated_grad_fwr_run(