nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: simpeg/simpeg
Pull request #1329 (2024-01-14 21:29:58)

Simpeg vector update
<!-- 
Thanks for contributing a pull request to SimPEG!
Remember to use a personal fork of SimPEG to propose changes.

Check out the stages of a pull request at
https://docs.simpeg.xyz/content/getting_started/contributing/pull-requests.html

Note that we are a team of volunteers and we appreciate your
patience during the review process.

Again, thanks for contributing!

Feel free to remove lines from this template that do not apply to you pull request.
-->

#### Summary
Update test_regularization.py to test vector smoothness derivatives. Update AmplitudeSmoothnessFirstOrder in vector.py so that the call matches the derivative.

#### PR Checklist
* [ ] If this is a work in progress PR, set as a Draft PR
* [ ] Linted my code according to the [style guides](https://docs.simpeg.xyz/content/getting_started/contributing/code-style.html).
* [ ] Added [tests](https://docs.simpeg.xyz/content/getting_started/practices.html#testing) to verify changes to the code.
* [ ] Added necessary documentation to any new functions/classes following the
      expect [style](https://docs.simpeg.xyz/content/getting_started/practices.html#documentation).
* [ ] Marked as ready for review (if this is was a draft PR), and converted 
      to a Pull Request
* [ ] Tagged ``@simpeg/simpeg-developers`` when ready for review.

#### Reference issue
<!--Example: write "Closes #NNNN" to automatically close that issue on merge.-->

#### What does this implement/fix?
<!--Please explain your changes.-->

#### Additional information
<!--Any additional information you think is important.-->


<!--
Once all tests pass and the code has been reviewed and approved, it will be merged into main
-->



Patch:
diff --git a/SimPEG/regularization/vector.py b/SimPEG/regularization/vector.py
index 0dd37aad1..2341b4d82 100644
--- a/SimPEG/regularization/vector.py
+++ b/SimPEG/regularization/vector.py
@@ -917,9 +917,11 @@ class AmplitudeSmoothnessFirstOrder(SparseSmoothness, BaseAmplitude):
         numpy.ndarray
             The regularization kernel function evaluated for the model provided.
         """
-        a = self.amplitude(m)
+        fm = self.cell_gradient * (self.mapping * self._delta_m(m)).reshape(
+            (self.regularization_mesh.nC, self.n_comp), order="F"
+        )
 
-        return self.cell_gradient @ a
+        return np.linalg.norm(fm, axis=1)
 
     def f_m_deriv(self, m) -> csr_matrix:
         r"""Derivative of the regularization kernel function.


Test patch:
diff --git a/tests/base/test_regularization.py b/tests/base/test_regularization.py
index 8e9f769b9..1f785fe99 100644
--- a/tests/base/test_regularization.py
+++ b/tests/base/test_regularization.py
@@ -580,6 +580,8 @@ class RegularizationTests(unittest.TestCase):
             reg.objfcts[0].f_m(model.flatten(order="F")), np.linalg.norm(model, axis=1)
         )
 
+        reg.test(model.flatten(order="F"))
+
 
 def test_WeightedLeastSquares():
     mesh = discretize.TensorMesh([3, 4, 5])