Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #195 from astrofrog/update-baseline-images-remote
Browse files Browse the repository at this point in the history
Switch to using remote baseline images and support Matplotlib 1.5.x
  • Loading branch information
astrofrog committed May 6, 2016
2 parents 61dcd3a + 55cf625 commit a45313c
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 32 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ env:
# to repeat them for all configurations.
- NUMPY_VERSION=stable
- ASTROPY_VERSION=stable
- CONDA_DEPENDENCIES='pyqt nose matplotlib=1.4.3 pillow'
- CONDA_DEPENDENCIES='pyqt nose matplotlib pillow'
- PIP_DEPENDENCIES='pytest-mpl'
- SETUP_XVFB=True
matrix:
- SETUP_CMD='egg_info'
- SETUP_CMD='test --remote-data'
Expand Down Expand Up @@ -67,10 +68,6 @@ matrix:

before_install:

# Make sure that interactive matplotlib backends work
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

# Make sure matplotlib uses PyQT not PySide
- export QT_API=pyqt

Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

- Fix image test that was sensitive to fonts on Debian. [#197]

- Fix testing for Matplotlib 1.5.x and switch to using remote baseline
images. [#195]

0.6 (2015-07-20)
----------------

Expand Down
11 changes: 11 additions & 0 deletions docs/slicing_datacubes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ If we don't want to reverse the dimensions plotted, we can simply do:

.. plot::
:context: reset
:align: center
:nofigs:

from astropy.wcs import WCS
from wcsaxes import datasets
hdu = datasets.fetch_l1448_co_hdu()
wcs = WCS(hdu.header)
image_data = hdu.data

.. plot::
:context:
:include-source:
:align: center

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ show-response = 1
minversion = 2.2
norecursedirs = build docs/_build
doctest_plus = enabled
addopts = --mpl --mpl-baseline-path=wcsaxes/tests/baseline_images
addopts = --mpl

[ah_bootstrap]
auto_use = True
Expand Down
2 changes: 1 addition & 1 deletion wcsaxes/coordinate_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,6 @@ def _update_grid_contour(self):
field[1:, 1:][reset] = np.nan

if len(tick_world_coordinates_values) > 0:
self._grid = self.parent_axes.contour(X, Y, field.transpose(), levels=tick_world_coordinates_values)
self._grid = self.parent_axes.contour(X, Y, field.transpose(), levels=np.sort(tick_world_coordinates_values))
else:
self._grid = None
13 changes: 13 additions & 0 deletions wcsaxes/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
from distutils.version import LooseVersion

import matplotlib

MPL_VERSION = LooseVersion(matplotlib.__version__)

ROOT = "https://astropy.stsci.edu/data/wcsaxes/2016-05-04T10:26:13.545916"

if MPL_VERSION >= LooseVersion('1.5.0'):
baseline_dir = ROOT + '/1.5.x/'
else:
baseline_dir = ROOT + '/1.4.x/'
Binary file removed wcsaxes/tests/baseline_images/changed_axis_units.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/contour_overlay.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/coords_overlay.png
Binary file not shown.
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/cube_slice_image.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/custom_frame.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/direct_init.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/image_plot.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/minor_ticks_image.png
Binary file not shown.
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/rcparams.png
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/set_coord_type.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/tick_angles.png
Binary file not shown.
Binary file not shown.
Binary file removed wcsaxes/tests/baseline_images/ticks_labels.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion wcsaxes/tests/setup_package.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def get_package_data():
return {'wcsaxes.tests': ['coveragerc', 'baseline_images/*.png', 'data/*']}
return {'wcsaxes.tests': ['coveragerc', 'baseline_images/*/*.png', 'data/*']}
10 changes: 5 additions & 5 deletions wcsaxes/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from .. import datasets
from ..frame import BaseFrame

from . import baseline_dir
from .test_images import BaseImageTests


class HexagonalFrame(BaseFrame):

spine_names = 'abcdef'
Expand All @@ -35,7 +35,7 @@ def update_spines(self):

class TestFrame(BaseImageTests):

@pytest.mark.mpl_image_compare(filename='custom_frame.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='custom_frame.png', tolerance=1.5)
def test_custom_frame(self):

wcs = WCS(self.msx_header)
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_custom_frame(self):

return fig

@pytest.mark.mpl_image_compare(filename='update_clip_path_rectangular.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='update_clip_path_rectangular.png', tolerance=1.5)
def test_update_clip_path_rectangular(self, tmpdir):

fig = plt.figure()
Expand All @@ -95,7 +95,7 @@ def test_update_clip_path_rectangular(self, tmpdir):

return fig

@pytest.mark.mpl_image_compare(filename='update_clip_path_nonrectangular.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='update_clip_path_nonrectangular.png', tolerance=1.5)
def test_update_clip_path_nonrectangular(self, tmpdir):

fig = plt.figure()
Expand All @@ -117,7 +117,7 @@ def test_update_clip_path_nonrectangular(self, tmpdir):

return fig

@pytest.mark.mpl_image_compare(filename='update_clip_path_change_wcs.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='update_clip_path_change_wcs.png', tolerance=1.5)
def test_update_clip_path_change_wcs(self, tmpdir):

# When WCS is changed, a new frame is created, so we need to make sure
Expand Down
34 changes: 18 additions & 16 deletions wcsaxes/tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from .. import datasets, WCSAxes

from . import baseline_dir


class BaseImageTests(object):

Expand All @@ -44,7 +46,7 @@ def setup_class(cls):

class TestBasic(BaseImageTests):

@pytest.mark.mpl_image_compare(filename='image_plot.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='image_plot.png', tolerance=1.5)
def test_image_plot(self):
# Test for plotting image and also setting values of ticks
fig = plt.figure(figsize=(6, 6))
Expand All @@ -55,7 +57,7 @@ def test_image_plot(self):
return fig

@remote_data
@pytest.mark.mpl_image_compare(filename='contour_overlay.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='contour_overlay.png', tolerance=1.5)
def test_contour_overlay(self):
# Test for overlaying contours on images
hdu_msx = datasets.fetch_msx_hdu()
Expand All @@ -78,7 +80,7 @@ def test_contour_overlay(self):

return fig

@pytest.mark.mpl_image_compare(filename='overlay_features_image.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='overlay_features_image.png', tolerance=1.5)
def test_overlay_features_image(self):

# Test for overlaying grid, changing format of ticks, setting spacing
Expand Down Expand Up @@ -111,7 +113,7 @@ def test_overlay_features_image(self):

return fig

@pytest.mark.mpl_image_compare(filename='curvlinear_grid_patches_image.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='curvlinear_grid_patches_image.png', tolerance=1.5)
def test_curvilinear_grid_patches_image(self):

# Overlay curvilinear grid and patches on image
Expand Down Expand Up @@ -142,7 +144,7 @@ def test_curvilinear_grid_patches_image(self):

return fig

@pytest.mark.mpl_image_compare(filename='cube_slice_image.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='cube_slice_image.png', tolerance=1.5)
def test_cube_slice_image(self):

# Test for cube slicing
Expand All @@ -167,7 +169,7 @@ def test_cube_slice_image(self):

return fig

@pytest.mark.mpl_image_compare(filename='cube_slice_image_lonlat.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='cube_slice_image_lonlat.png', tolerance=1.5)
def test_cube_slice_image_lonlat(self):

# Test for cube slicing. Here we test with longitude and latitude since
Expand All @@ -186,7 +188,7 @@ def test_cube_slice_image_lonlat(self):

return fig

@pytest.mark.mpl_image_compare(filename='changed_axis_units.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='changed_axis_units.png', tolerance=1.5)
def test_changed_axis_units(self):
# Test to see if changing the units of axis works
fig = plt.figure()
Expand All @@ -203,7 +205,7 @@ def test_changed_axis_units(self):

return fig

@pytest.mark.mpl_image_compare(filename='minor_ticks_image.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='minor_ticks_image.png', tolerance=1.5)
def test_minor_ticks(self):
# Test for drawing minor ticks
fig = plt.figure()
Expand All @@ -221,7 +223,7 @@ def test_minor_ticks(self):

return fig

@pytest.mark.mpl_image_compare(filename='ticks_labels.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='ticks_labels.png', tolerance=1.5)
def test_ticks_labels(self):
fig = plt.figure(figsize=(6, 6))
ax = WCSAxes(fig, [0.1, 0.1, 0.7, 0.7], wcs=None)
Expand All @@ -248,7 +250,7 @@ def test_ticks_labels(self):

return fig

@pytest.mark.mpl_image_compare(filename='rcparams.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='rcparams.png', tolerance=1.5)
def test_rcparams(self):
# Test default style (matplotlib.rcParams) for ticks and gridlines
with rc_context({
Expand All @@ -269,7 +271,7 @@ def test_rcparams(self):
ax.coords[1].set_ticks(exclude_overlapping=True)
return fig

@pytest.mark.mpl_image_compare(filename='tick_angles.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='tick_angles.png', tolerance=1.5)
def test_tick_angles(self):
# Test that tick marks point in the correct direction, even when the
# axes limits extend only over a few FITS pixels. Addresses #45, #46.
Expand All @@ -289,7 +291,7 @@ def test_tick_angles(self):
ax.coords['dec'].set_ticks(color='red', size=20)
return fig

@pytest.mark.mpl_image_compare(filename='tick_angles_non_square_axes.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='tick_angles_non_square_axes.png', tolerance=1.5)
def test_tick_angles_non_square_axes(self):
# Test that tick marks point in the correct direction, even when the
# axes limits extend only over a few FITS pixels, and the axes are
Expand All @@ -310,7 +312,7 @@ def test_tick_angles_non_square_axes(self):
ax.coords['dec'].set_ticks(color='red', size=20)
return fig

@pytest.mark.mpl_image_compare(filename='set_coord_type.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='set_coord_type.png', tolerance=1.5)
def test_set_coord_type(self):
# Test for setting coord_type
fig = plt.figure(figsize=(3, 3))
Expand All @@ -327,7 +329,7 @@ def test_set_coord_type(self):
ax.coords[1].set_ticks(exclude_overlapping=True)
return fig

@pytest.mark.mpl_image_compare(filename='test_ticks_regression_1.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='test_ticks_regression_1.png', tolerance=1.5)
def test_ticks_regression(self):
# Regression test for a bug that caused ticks aligned exactly with a
# sampled frame point to not appear. This also checks that tick labels
Expand All @@ -349,7 +351,7 @@ def test_ticks_regression(self):
ax.coords[1].set_ticklabel_position('all')
return fig

@pytest.mark.mpl_image_compare(filename='test_axislabels_regression.png', savefig_kwargs={'bbox_inches': 'tight'}, tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='test_axislabels_regression.png', savefig_kwargs={'bbox_inches': 'tight'}, tolerance=1.5)
def test_axislabels_regression(self):
# Regression test for a bug that meant that if tick labels were made
# invisible with ``set_visible(False)``, they were still added to the
Expand All @@ -363,7 +365,7 @@ def test_axislabels_regression(self):
ax.coords[1].ticklabels.set_visible(False)
return fig

@pytest.mark.mpl_image_compare(savefig_kwargs={'bbox_inches': 'tight'},
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, savefig_kwargs={'bbox_inches': 'tight'},
tolerance=1.5)
def test_noncelestial_angular(self, tmpdir):
# Regression test for a bug that meant that when passing a WCS that had
Expand Down
8 changes: 5 additions & 3 deletions wcsaxes/tests/test_transform_coord_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from .test_images import BaseImageTests
from ..transforms import CurvedTransform

from . import baseline_dir

requires_astropy_10 = pytest.mark.skipif(str(LooseVersion(astropy.__version__) < LooseVersion("1.0")))

# Create fake transforms that roughly mimic a polar projection
Expand Down Expand Up @@ -58,7 +60,7 @@ def inverted(self):

class TestTransformCoordMeta(BaseImageTests):

@pytest.mark.mpl_image_compare(filename='coords_overlay.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='coords_overlay.png', tolerance=1.5)
def test_coords_overlay(self):

# Set up a simple WCS that maps pixels to non-projected distances
Expand Down Expand Up @@ -106,7 +108,7 @@ def test_coords_overlay(self):
return fig

@requires_astropy_10
@pytest.mark.mpl_image_compare(filename='coords_overlay_auto_coord_meta.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='coords_overlay_auto_coord_meta.png', tolerance=1.5)
def test_coords_overlay_auto_coord_meta(self):

fig = plt.figure(figsize=(4, 4))
Expand All @@ -128,7 +130,7 @@ def test_coords_overlay_auto_coord_meta(self):

return fig

@pytest.mark.mpl_image_compare(filename='direct_init.png', tolerance=1.5)
@pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, filename='direct_init.png', tolerance=1.5)
def test_direct_init(self):

s = DistanceToLonLat(R=6378.273)
Expand Down

0 comments on commit a45313c

Please sign in to comment.