Skip to content

Commit

Permalink
Merge pull request #1964 from QuLogic/parametrized-proj-tests
Browse files Browse the repository at this point in the history
Parametrize projection test images
  • Loading branch information
greglucas authored Dec 12, 2021
2 parents 27c6118 + 5791052 commit 55b7b5f
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 73 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 41 additions & 73 deletions lib/cartopy/tests/mpl/test_mpl_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ def test_global_hexbin_wrap_transform():
return ax.figure


@pytest.mark.mpl_image_compare(filename='global_map.png', tolerance=0.55)
def test_global_map():
ax = plt.axes(projection=ccrs.Robinson())
# ax.coastlines()
# ax.gridlines(5)

ax.plot(-0.08, 51.53, 'o', transform=ccrs.PlateCarree())

ax.plot([-0.08, 132], [51.53, 43.17], color='red',
transform=ccrs.PlateCarree())

ax.plot([-0.08, 132], [51.53, 43.17], color='blue',
transform=ccrs.Geodetic())
return ax.figure


@pytest.mark.filterwarnings("ignore:Unable to determine extent")
@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(filename='simple_global.png')
Expand All @@ -177,70 +161,54 @@ def test_simple_global():

@pytest.mark.filterwarnings("ignore:Unable to determine extent")
@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(filename='multiple_projections5.png',
tolerance=2.05)
def test_multiple_projections():

projections = [ccrs.PlateCarree(),
ccrs.Robinson(),
ccrs.RotatedPole(pole_latitude=45, pole_longitude=180),
ccrs.OSGB(approx=True),
ccrs.TransverseMercator(approx=True),
ccrs.Mercator(min_latitude=-85., max_latitude=85.),
ccrs.LambertCylindrical(),
ccrs.Miller(),
ccrs.Gnomonic(),
ccrs.Stereographic(),
ccrs.NorthPolarStereo(),
ccrs.SouthPolarStereo(),
ccrs.Orthographic(),
ccrs.Mollweide(),
ccrs.InterruptedGoodeHomolosine(emphasis='land'),
ccrs.EckertI(),
ccrs.EckertII(),
ccrs.EckertIII(),
ccrs.EckertIV(),
ccrs.EckertV(),
ccrs.EckertVI(),
]

rows = np.ceil(len(projections) / 5).astype(int)

fig = plt.figure(figsize=(10, 2 * rows))
for i, prj in enumerate(projections, 1):
ax = fig.add_subplot(rows, 5, i, projection=prj)

ax.set_global()

ax.coastlines(resolution="110m")

ax.plot(-0.08, 51.53, 'o', transform=ccrs.PlateCarree())
ax.plot([-0.08, 132], [51.53, 43.17], color='red',
transform=ccrs.PlateCarree())
ax.plot([-0.08, 132], [51.53, 43.17], color='blue',
transform=prj.as_geodetic())

return fig


@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(filename='multiple_projections520.png',
tolerance=0.641)
def test_multiple_projections_520():
# Test projections added in Proj 5.2.0.
@pytest.mark.parametrize('proj', [
ccrs.EckertI,
ccrs.EckertII,
ccrs.EckertIII,
ccrs.EckertIV,
ccrs.EckertV,
ccrs.EckertVI,
ccrs.EqualEarth,
ccrs.Gnomonic,
pytest.param((ccrs.InterruptedGoodeHomolosine, dict(emphasis='land')),
id='InterruptedGoodeHomolosine'),
ccrs.LambertCylindrical,
pytest.param((ccrs.Mercator, dict(min_latitude=-85, max_latitude=85)),
id='Mercator'),
ccrs.Miller,
ccrs.Mollweide,
ccrs.NorthPolarStereo,
ccrs.Orthographic,
pytest.param((ccrs.OSGB, dict(approx=True)), id='OSGB'),
ccrs.PlateCarree,
ccrs.Robinson,
pytest.param((ccrs.RotatedPole,
dict(pole_latitude=45, pole_longitude=180)),
id='RotatedPole'),
ccrs.Stereographic,
ccrs.SouthPolarStereo,
pytest.param((ccrs.TransverseMercator, dict(approx=True)),
id='TransverseMercator'),
])
@pytest.mark.mpl_image_compare(
tolerance=(2.61 if MPL_VERSION.release[:2] == (3, 1) else
0.97 if MPL_VERSION.release[:2] < (3, 5) else 0.5),
style='mpl20')
def test_global_map(proj):
if isinstance(proj, tuple):
proj, kwargs = proj
else:
kwargs = {}
proj = proj(**kwargs)

fig = plt.figure(figsize=(2, 2))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.EqualEarth())

ax = fig.add_subplot(projection=proj)
ax.set_global()

ax.coastlines()
ax.coastlines(resolution="110m")

ax.plot(-0.08, 51.53, 'o', transform=ccrs.PlateCarree())

ax.plot([-0.08, 132], [51.53, 43.17], color='red',
transform=ccrs.PlateCarree())

ax.plot([-0.08, 132], [51.53, 43.17], color='blue',
transform=ccrs.Geodetic())

Expand Down

0 comments on commit 55b7b5f

Please sign in to comment.