Skip to content

Commit 127d9cc

Browse files
committed
Add tests for check_if_geo_coords function
1 parent a0e02be commit 127d9cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

climada/util/test/test_coordinates.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,23 @@ def data_arrays_resampling_demo():
342342
class TestFunc(unittest.TestCase):
343343
"""Test auxiliary functions"""
344344

345+
def test_check_geo_coords(self):
346+
"""Test the check_if_geo_coords function"""
347+
# test correct geographical coords
348+
lat, lon = np.array([0, -2, 5]), np.array([-179, 175, 178])
349+
self.assertEqual(u_coord.check_if_geo_coords(lat, lon), True)
350+
# test wrong lat
351+
lat, lon = np.array([0, 200, 5]), np.array([-179, 175, 178])
352+
self.assertEqual(u_coord.check_if_geo_coords(lat, lon), False)
353+
# test wrong lon
354+
lat, lon = np.array([0, -2, 5]), np.array([-400, 175, 176])
355+
self.assertEqual(u_coord.check_if_geo_coords(lat, lon), False)
356+
lat, lon = np.array([0, -2, 5]), np.array([700, 1000, 800])
357+
self.assertEqual(u_coord.check_if_geo_coords(lat, lon), False)
358+
# test wrong extent
359+
lat, lon = np.array([0, -2, 5]), np.array([-179, 175, 370])
360+
self.assertEqual(u_coord.check_if_geo_coords(lat, lon), False)
361+
345362
def test_lon_normalize(self):
346363
"""Test the longitude normalization function"""
347364
data = np.array([-180, 20.1, -30, 190, -350])

0 commit comments

Comments
 (0)