Skip to content

Commit

Permalink
Added and edited tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenworsley committed Jun 26, 2019
1 parent 3dfde16 commit 2ddd73c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/cartopy/tests/crs/test_mollweide.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_default():
assert_almost_equal(np.array(moll.x_limits),
[-18040095.6961473, 18040095.6961473])
assert_almost_equal(np.array(moll.y_limits),
[-9020047.8480736, 9020047.8480736])
[-9001417.6133785, 9001417.6133785])


def test_sphere_globe():
Expand All @@ -47,7 +47,7 @@ def test_sphere_globe():
check_proj_params('moll', moll, other_args)

assert_almost_equal(moll.x_limits, [-2828.4271247, 2828.4271247])
assert_almost_equal(moll.y_limits, [-1414.2135624, 1414.2135624])
assert_almost_equal(moll.y_limits, [-1411.29261, 1411.29261])


def test_ellipse_globe():
Expand All @@ -62,7 +62,7 @@ def test_ellipse_globe():

# Limits are the same as default since ellipses are not supported.
assert_almost_equal(moll.x_limits, [-18040095.6961473, 18040095.6961473])
assert_almost_equal(moll.y_limits, [-9020047.8480736, 9020047.8480736])
assert_almost_equal(moll.y_limits, [-9001417.6133785, 9001417.6133785])


def test_eccentric_globe():
Expand All @@ -78,7 +78,7 @@ def test_eccentric_globe():

# Limits are the same as spheres since ellipses are not supported.
assert_almost_equal(moll.x_limits, [-2828.4271247, 2828.4271247])
assert_almost_equal(moll.y_limits, [-1414.2135624, 1414.2135624])
assert_almost_equal(moll.y_limits, [-1411.29261, 1411.29261])


def test_offset():
Expand All @@ -100,7 +100,7 @@ def test_central_longitude(lon):
[-18040095.6961473, 18040095.6961473],
decimal=5)
assert_almost_equal(np.array(moll.y_limits),
[-9020047.8480736, 9020047.8480736])
[-9001417.6133785, 9001417.6133785])


def test_grid():
Expand All @@ -116,7 +116,7 @@ def test_grid():
assert_almost_equal(np.array(moll.x_limits),
[-2, 2])
assert_almost_equal(np.array(moll.y_limits),
[-1, 1])
[-0.9979346, 0.9979346])

lats = np.arange(0, 91, 5)[::-1]
lons = np.full_like(lats, 90)
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_sphere_transform():
[-2.8284271247461903, 2.8284271247461903],
decimal=2)
assert_almost_equal(np.array(moll.y_limits),
[-1.4142135623730951, 1.4142135623730951])
[-1.4112926, 1.4112926])

result = moll.transform_point(-75.0, -50.0, geodetic)
assert_almost_equal(result, [0.1788845, -0.9208758])
Expand Down
16 changes: 16 additions & 0 deletions lib/cartopy/tests/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ def test_same_points_on_boundary_2(self):

assert abs(1200 - projected.area) < 1e-5

def test_mollweide_pole(self):
# Geometry comes from a matplotlib contourf (see #1333)
wkt = ('POLYGON ((-143.4375 88.9979823936324, '
'-149.0625 89.375, '
'-149.0625 88.46018604660821, '
'-147.1875 88.42282488713046, '
'-143.4375 88.9979823936324))')

geom = shapely.wkt.loads(wkt)
source, target = ccrs.PlateCarree(), ccrs.Mollweide()
projected = target.project_geometry(geom, source)
# Before restricting the pole from the Mollweide projection,
# this would contain the entire boundary.
for poly in projected:
assert len(poly.exterior.coords) < 10


class TestQuality(object):
def setup_class(self):
Expand Down

0 comments on commit 2ddd73c

Please sign in to comment.