Skip to content

Commit 26dddc0

Browse files
included polygon case in test of the function
1 parent 3f066ab commit 26dddc0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

climada/util/test/test_coordinates.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,7 @@ def test_bounding_box_global(self):
23052305

23062306
def test_bounding_box_from_countries(self):
23072307
"""Test for a list of ISO country codes."""
2308+
# Italy is a multipolygon geometry
23082309
result = u_coord.bounding_box_from_countries(
23092310
["ITA"], buffer=1.0
23102311
) # Testing with Italy (ITA)
@@ -2314,7 +2315,21 @@ def test_bounding_box_from_countries(self):
23142315
34.48924388200004,
23152316
19.517425977000073,
23162317
48.08521494500006,
2317-
] # Italy's bounding box
2318+
] # Italy's bounding box with 1 degree buffer
2319+
np.testing.assert_array_almost_equal(result, expected)
2320+
2321+
# Switzerland is a polygon geometry
2322+
result = u_coord.bounding_box_from_countries(
2323+
["CHE"], buffer=0.0
2324+
) # Testing with Switzerland (CHE)
2325+
# Real expected bounds for Switzerland (calculated or manually known)
2326+
expected = [
2327+
5.954809204000128,
2328+
45.82071848599999,
2329+
10.466626831000013,
2330+
47.801166077000076,
2331+
] # CHE's bounding box with 0 degree buffer
2332+
np.testing.assert_array_almost_equal(result, expected)
23182333

23192334
# invalid input
23202335
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)