You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our forward models for the different geometries (points, prisms, tesseroids) allow to take multiple bodies as inputs, returning a single array as the resulting field generated by every one of these bodies on the computation points.
One of the properties of these forward models is their linearity: the resulting field for all the bodies should be equal to the sum of the individual fields.
Although this property is easily readable from the code, it might be wise to add functions that actually test them.
We could add test_linearity functions for each geometry that compares the resulting field of passing a set of bodies to the resulting field of computing the fields of each one separately and then sum them up.
Through pytests.mark.parametrize we could write a single function per geometry, adding the field as a parameter.
For example:
@pytest.mark.parametrize("field", ("potential", "g_z", ...))deftest_linearity(field):
""" Test linearity of the forward model """
...
Are you willing to help implement and maintain this feature? Yes, but I would love to help anyone motivated to tackle it. 💪🏼
My plan is to add a parametrized test_linearity for each geometry (point sources, prisms and tesseroids), comparing the field produced by the full set of bodies against the sum of the fields of each body computed separately, with field as the parametrize argument as suggested above. I'd place them in the existing per-geometry modules (test_point_gravity.py, test_prism.py, test_tesseroid.py).
Two quick questions before I start:
Would you prefer a single PR covering all geometries, or one per geometry to keep reviews small?
Should the magnetic forward models (prism_magnetic, dipole) be covered too, or do we keep this scoped to gravity?
Hi @manduinca! Thanks for offering help with this, it's much appreciated!
Your idea sounds good: splitting the tests for each geometry and them parametrize by field sounds right. It would be nice to include linearity tests for both gravity and magnetic fields. I think including all of them in a single PR should be enough. I suspect it won't be too large, so feel free to open a single one.
Thanks again, and let me know if you need any help!
Activity
manduinca commentedon Jul 15, 2026
Hi! I'd like to work on this one.
My plan is to add a parametrized
test_linearityfor each geometry (point sources, prisms and tesseroids), comparing the field produced by the full set of bodies against the sum of the fields of each body computed separately, withfieldas the parametrize argument as suggested above. I'd place them in the existing per-geometry modules (test_point_gravity.py,test_prism.py,test_tesseroid.py).Two quick questions before I start:
prism_magnetic,dipole) be covered too, or do we keep this scoped to gravity?santisoler commentedon Jul 22, 2026
Hi @manduinca! Thanks for offering help with this, it's much appreciated!
Your idea sounds good: splitting the tests for each geometry and them parametrize by field sounds right. It would be nice to include linearity tests for both gravity and magnetic fields. I think including all of them in a single PR should be enough. I suspect it won't be too large, so feel free to open a single one.
Thanks again, and let me know if you need any help!