Skip to content

Commit cb5db5e

Browse files
committed
Update tests lon_normalize
1 parent 8275b6b commit cb5db5e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

climada/util/test/test_coordinates.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,19 @@ def test_estimate_matching_threshold(self):
453453

454454
def test_lon_normalize(self):
455455
"""Test the longitude normalization function"""
456-
data = np.array([-180, 20.1, -30, 190, -350])
456+
data = np.array([-180, 20.1, -30, 181])
457457

458458
# test in place operation
459459
u_coord.lon_normalize(data)
460-
np.testing.assert_array_almost_equal(data, [180, 20.1, -30, -170, 10])
460+
np.testing.assert_array_almost_equal(data, [180, 20.1, -30, -179])
461461

462462
# test with specific center and return value
463463
data = u_coord.lon_normalize(data, center=-170)
464-
np.testing.assert_array_almost_equal(data, [-180, -339.9, -30, -170, 10])
464+
np.testing.assert_array_almost_equal(data, [-180, -339.9, -30, -179])
465465

466466
# test with center determined automatically (which is 280.05)
467467
data = u_coord.lon_normalize(data, center=None)
468-
np.testing.assert_array_almost_equal(data, [180, 380.1, 330, 190, 370])
468+
np.testing.assert_array_almost_equal(data, [180, 380.1, 330, 181])
469469

470470
def test_latlon_bounds(self):
471471
"""Test latlon_bounds function"""
@@ -524,7 +524,6 @@ def test_dist_approx_pass(self):
524524
# lat1, lon1, lat2, lon2, dist_equirect, dist_geosphere
525525
[45.5, -32.1, 14, 56, 7702.88906574, 8750.64119051],
526526
[45.5, 147.8, 14, -124, 7709.82781473, 8758.34146833],
527-
[45.5, 507.9, 14, -124, 7702.88906574, 8750.64119051],
528527
[45.5, -212.2, 14, -124, 7709.82781473, 8758.34146833],
529528
[-3, -130.1, 4, -30.5, 11079.7217421, 11087.0352544],
530529
]
@@ -628,8 +627,8 @@ def test_dist_approx_log_pass(self):
628627
def test_dist_approx_batch_pass(self):
629628
"""Test batch-execution of approximate distance functions"""
630629

631-
lat1 = np.array([[45.5, -3.0, 45.5, 45.5], [45.5, 45.5, 45.5, -3.0]])
632-
lon1 = np.array([[-32.1, -130.1, 147.8, 507.9], [-212.2, 507.9, -32.1, -130.1]])
630+
lat1 = np.array([[45.5, -3.0, 45.5], [45.5, 45.5, -3.0]])
631+
lon1 = np.array([[-32.1, -130.1, 147.8], [-212.2, -32.1, -130.1]])
633632
lat2 = np.array([[14.0, 14.0, 4.0], [4.0, 14.0, 14.0]])
634633
lon2 = np.array([[56.0, -124.0, -30.5], [-30.5, -124.0, 56.0]])
635634

@@ -641,11 +640,9 @@ def test_dist_approx_batch_pass(self):
641640
[7702.88906574, 7967.66578334, 4613.1634431],
642641
[19389.5254652, 2006.65638992, 11079.7217421],
643642
[7960.66983129, 7709.82781473, 14632.55958021],
644-
[7967.66578334, 7702.88906574, 14639.95139706],
645643
],
646644
[
647645
[14632.55958021, 7709.82781473, 7960.66983129],
648-
[14639.95139706, 7702.88906574, 7967.66578334],
649646
[4613.1634431, 7967.66578334, 7702.88906574],
650647
[11079.7217421, 2006.65638992, 19389.5254652],
651648
],
@@ -657,7 +654,7 @@ def test_dist_approx_batch_pass(self):
657654

658655
dist, vec = u_coord.dist_approx(lat1, lon1, lat2, lon2, log=True)
659656
np.testing.assert_array_almost_equal(dist, test_data)
660-
self.assertEqual(vec.shape, (2, 4, 3, 2))
657+
self.assertEqual(vec.shape, (2, 3, 3, 2))
661658

662659
def test_get_gridcellarea(self):
663660
"""Test get_gridcellarea function to calculate the gridcellarea from a given latitude"""

0 commit comments

Comments
 (0)