@@ -1256,7 +1256,7 @@ def repeat_coord_pass(self, dist):
12561256 # Check copied coordinates have same neighbors
12571257 self .assertEqual (neighbors [2 ], neighbors [0 ])
12581258
1259- def antimeridian_warning (self , dist ):
1259+ def distance_threshold_warning_antimeridian (self , dist ):
12601260 """Check that a warning is raised when minimum distance greater than threshold"""
12611261 # Load input
12621262 centroids , exposures = self .data_antimeridian_values ()
@@ -1285,7 +1285,7 @@ def test_approx_repeat_coord_pass(self):
12851285
12861286 def test_approx_antimeridian_warning (self ):
12871287 """Call normal_warning test for approximate distance"""
1288- self .antimeridian_warning ("approx" )
1288+ self .distance_threshold_warning_antimeridian ("approx" )
12891289
12901290 def test_haver_normal_pass (self ):
12911291 """Call normal_pass test for haversine distance"""
@@ -1301,7 +1301,7 @@ def test_haver_repeat_coord_pass(self):
13011301
13021302 def test_haver_antimeridian_warning (self ):
13031303 """Call normal_warning test for haversine distance"""
1304- self .antimeridian_warning ("haversine" )
1304+ self .distance_threshold_warning_antimeridian ("haversine" )
13051305
13061306 def test_euc_normal_pass (self ):
13071307 """Call normal_pass test for euclidean distance"""
@@ -1317,7 +1317,7 @@ def test_euc_repeat_coord_pass(self):
13171317
13181318 def test_euc_antimeridian_warning (self ):
13191319 """Call normal_warning test for euclidean distance"""
1320- self .antimeridian_warning ("euclidean" )
1320+ self .distance_threshold_warning_antimeridian ("euclidean" )
13211321
13221322 def test_diff_outcomes (self ):
13231323 """Different NN interpolation outcomes"""
@@ -1502,6 +1502,27 @@ def test_nearest_neighbor_haversine_invalid_unit(self):
15021502 u_coord .NEAREST_NEIGHBOR_THRESHOLD ,
15031503 )
15041504
1505+ def antimeridian_warning_invalid_unit (self ):
1506+ """Check that a warning is raised when coords are
1507+ non-degree and check_antimeridian is True"""
1508+
1509+ self .setUp_match_coordinates ()
1510+ coords_to_assign = np .deg2rad (self .coords_to_assign ) * EARTH_RADIUS_KM # to km
1511+ coords = np .deg2rad (self .coords ) * EARTH_RADIUS_KM
1512+
1513+ with self .assertLogs ("climada.util.coordinates" , level = "WARNING" ) as cm :
1514+ neighbors = u_coord .match_coordinates (
1515+ coords_to_assign , coords , check_antimeridian = True
1516+ )
1517+ self .assertIn (
1518+ "Handling of antimeridian crossing is not implemented for non-degree"
1519+ " coordinates ('check_antimeridian' has been set to False). Please use"
1520+ " degree-based coordinates system if you want to enable antimeridian crossing." ,
1521+ cm .output [1 ],
1522+ )
1523+
1524+ np .testing .assert_array_equal (neighbors , self .data_ref_antimeridian ())
1525+
15051526
15061527class TestGetGeodata (unittest .TestCase ):
15071528 def test_nat_earth_resolution_pass (self ):
0 commit comments