Skip to content

Commit

Permalink
add unit tests for L2E projection
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibHlln committed Aug 27, 2024
1 parent 1a48244 commit aafe3f5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/cartopy/tests/crs/test_lambert_conformal.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,29 @@ def test_single_npole(self):
assert_array_almost_equal(n_pole_crs.y_limits,
expected_y,
decimal=0)


class TestL2E:
def setup_class(self):
self.point_a = (48.13277955695077, 1.4868268900254693)
self.point_b = (48.68412929316207, -2.3188020040300126)
self.src_crs = ccrs.PlateCarree()
self.nan = float('nan')

def test_default(self):
proj = ccrs.L2E()
res = proj.transform_point(*self.point_a, src_crs=self.src_crs)
np.testing.assert_array_almost_equal(res,
(536745.89626, 2348522.77899),
decimal=5)
res = proj.transform_point(*self.point_b, src_crs=self.src_crs)
np.testing.assert_array_almost_equal(res,
(257266.90019, 2419663.00145),
decimal=5)

def test_nan(self):
proj = ccrs.L2E()
res = proj.transform_point(0.0, float('nan'), src_crs=self.src_crs)
assert np.all(np.isnan(res))
res = proj.transform_point(float('nan'), 0.0, src_crs=self.src_crs)
assert np.all(np.isnan(res))

0 comments on commit aafe3f5

Please sign in to comment.