From 2e1c831b961e2877ee6b727e4e43e3558451f86a Mon Sep 17 00:00:00 2001 From: Mark Wieczorek Date: Fri, 12 Apr 2024 00:02:20 +0200 Subject: [PATCH] Add more tests for Sphere class --- boule/tests/test_sphere.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boule/tests/test_sphere.py b/boule/tests/test_sphere.py index 31c9fe7f..6e1e222d 100644 --- a/boule/tests/test_sphere.py +++ b/boule/tests/test_sphere.py @@ -72,6 +72,23 @@ def test_check_geocentric_grav_const(): assert len(warn) >= 1 +def test_normal_gravity_computed_on_internal_point(sphere): + """ + Check if warn is raised if height is negative for normal_gravity, + normal_gravity_potential, and normal_gravitational_potential. + """ + latitude = np.linspace(-90, 90, 100) + with warnings.catch_warnings(record=True) as warn: + sphere.normal_gravity(latitude, height=-10) + assert len(warn) >= 1 + with warnings.catch_warnings(record=True) as warn: + sphere.normal_gravity_potential(latitude, height=-10) + assert len(warn) >= 1 + with warnings.catch_warnings(record=True) as warn: + sphere.normal_gravitational_potential(latitude, height=-10) + assert len(warn) >= 1 + + @pytest.mark.parametrize("si_units", [False, True], ids=["mGal", "SI"]) def test_normal_gravity_pole_equator(sphere, si_units): """