@@ -2297,15 +2297,15 @@ def test_mask_raster_with_geometry(self):
22972297class TestBoundsFromUserInput (unittest .TestCase ):
22982298 """Unit tests for the bounds_from_user_input function."""
22992299
2300- def global_bounding_box (self ):
2300+ def test_bounding_box_global (self ):
23012301 """Test for 'global' area selection."""
2302- result = u_coord .global_bounding_box ()
2302+ result = u_coord .bounding_box_global ()
23032303 expected = (- 180 , - 90 , 180 , 90 )
23042304 np .testing .assert_almost_equal (result , expected )
23052305
2306- def test_get_country_bounding_box (self ):
2306+ def test_bounding_box_from_countries (self ):
23072307 """Test for a list of ISO country codes."""
2308- result = u_coord .get_country_bounding_box (
2308+ result = u_coord .bounding_box_from_countries (
23092309 ["ITA" ], buffer = 1.0
23102310 ) # Testing with Italy (ITA)
23112311 # Real expected bounds for Italy (calculated or manually known)
@@ -2316,56 +2316,57 @@ def test_get_country_bounding_box(self):
23162316 48.08521494500006 ,
23172317 ] # Italy's bounding box
23182318
2319- def test_bounds_from_cardinal_bounds (self ):
2319+ # invalid input
2320+ with self .assertRaises (ValueError ):
2321+ u_coord .bounding_box_from_countries (["invalid_ISO" , "DEU" ])
2322+
2323+ def test_bounding_box_from_cardinal_bounds (self ):
23202324 """Test for conversion from cardinal bounds to bounds."""
23212325 np .testing .assert_array_almost_equal (
2322- u_coord .bounds_from_cardinal_bounds (
2326+ u_coord .bounding_box_from_cardinal_bounds (
23232327 northern = 90 , southern = - 20 , eastern = 30 , western = 20
23242328 ),
23252329 (20 , - 20 , 30 , 90 ),
23262330 )
23272331 np .testing .assert_array_almost_equal (
2328- u_coord .bounds_from_cardinal_bounds (
2332+ u_coord .bounding_box_from_cardinal_bounds (
23292333 northern = 90 , southern = - 20 , eastern = 20 , western = 30
23302334 ),
23312335 (30 , - 20 , 380 , 90 ),
23322336 )
23332337 np .testing .assert_array_almost_equal (
2334- u_coord .bounds_from_cardinal_bounds (
2338+ u_coord .bounding_box_from_cardinal_bounds (
23352339 northern = 90 , southern = - 20 , eastern = 170 , western = - 170
23362340 ),
23372341 (- 170 , - 20 , 170 , 90 ),
23382342 )
23392343 np .testing .assert_array_almost_equal (
2340- u_coord .bounds_from_cardinal_bounds (
2344+ u_coord .bounding_box_from_cardinal_bounds (
23412345 northern = 90 , southern = - 20 , eastern = - 170 , western = 170
23422346 ),
23432347 (170 , - 20 , 190 , 90 ),
23442348 )
23452349 np .testing .assert_array_almost_equal (
2346- u_coord .bounds_from_cardinal_bounds (
2350+ u_coord .bounding_box_from_cardinal_bounds (
23472351 northern = 90 , southern = - 20 , eastern = 170 , western = 175
23482352 ),
23492353 (175 , - 20 , 530 , 90 ),
23502354 )
23512355
23522356 # some invalid cases
23532357 with self .assertRaises (TypeError ):
2354- u_coord .bounds_from_cardinal_bounds (southern = - 20 , eastern = 30 , western = 20 )
2358+ u_coord .bounding_box_from_cardinal_bounds (
2359+ southern = - 20 , eastern = 30 , western = 20
2360+ )
23552361 with self .assertRaises (TypeError ):
2356- u_coord .bounds_from_cardinal_bounds ([90 , - 20 , 30 , 20 ])
2362+ u_coord .bounding_box_from_cardinal_bounds ([90 , - 20 , 30 , 20 ])
23572363 with self .assertRaises (TypeError ):
2358- u_coord .bounds_from_cardinal_bounds (90 , - 20 , 30 , 20 )
2364+ u_coord .bounding_box_from_cardinal_bounds (90 , - 20 , 30 , 20 )
23592365 with self .assertRaises (TypeError ):
2360- u_coord .bounds_from_cardinal_bounds (
2366+ u_coord .bounding_box_from_cardinal_bounds (
23612367 northern = "90" , southern = - 20 , eastern = 30 , western = 20
23622368 )
23632369
2364- def test_invalid_input_string (self ):
2365- """Test for invalid string input."""
2366- with self .assertRaises (Exception ):
2367- u_coord .get_bound ("invalid_ISO" )
2368-
23692370
23702371# Execute Tests
23712372if __name__ == "__main__" :
0 commit comments