Skip to content

Commit 9b56aae

Browse files
committed
Add test estimate_matching_threshold
1 parent 2afd553 commit 9b56aae

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

climada/util/test/test_coordinates.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,21 @@ def test_check_geo_coords(self):
436436
str(cm.exception),
437437
)
438438

439+
def test_estimate_matching_threshold(self):
440+
"""Test the estimate_matching_threshold function"""
441+
coords_pass = np.array([[10, 20], [10, 20.001], [10, 20.002]])
442+
threshold_pass = u_coord.estimate_matching_threshold(coords_pass)
443+
self.assertAlmostEqual(threshold_pass, 0.002, places=6)
444+
445+
coords_fail = np.array([[0, 0]])
446+
with self.assertRaises(ValueError) as cm:
447+
u_coord.estimate_matching_threshold(coords_fail)
448+
self.assertIn(
449+
"The coordinate assignement threshold cannot be"
450+
"estimated for a single coordinate. Please set the threshold explicitly",
451+
str(cm.exception),
452+
)
453+
439454
def test_lon_normalize(self):
440455
"""Test the longitude normalization function"""
441456
data = np.array([-180, 20.1, -30, 190, -350])

0 commit comments

Comments
 (0)