diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18b06ab..b5cd26f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: - name: tests run: | - python -m pytest + python -m pytest --mpl link-check: runs-on: ubuntu-latest diff --git a/docs/release-notes.rst b/docs/release-notes.rst index d9b2eba..bc03235 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -17,6 +17,7 @@ Internal Changes ^^^^^^^^^^^^^^^^ * Update pre-commit versions and configuration by `Katelyn FitzGerald`_ in (:pr:`247`) * Remove M1 workaround for CI and tokens that are no longer needed by `Katelyn FitzGerald`_ in (:pr:`232`) +* Modify tests to avoid hitting an unrelated Xarray bug and turn on image comparison testing by `Katelyn FitzGerald`_ in (:pr:`257`) Testing ^^^^^^^ diff --git a/tests/baseline/test_plot_contour_labels.png b/tests/baseline/test_plot_contour_labels.png index 5ee8411..5b26a8f 100644 Binary files a/tests/baseline/test_plot_contour_labels.png and b/tests/baseline/test_plot_contour_labels.png differ diff --git a/tests/baseline/test_xr_add_cyclic_longitudes.png b/tests/baseline/test_xr_add_cyclic_longitudes.png index 8e8a5c8..6c50d7f 100644 Binary files a/tests/baseline/test_xr_add_cyclic_longitudes.png and b/tests/baseline/test_xr_add_cyclic_longitudes.png differ diff --git a/tests/test_taylor.py b/tests/test_taylor.py index a76069b..de7b310 100644 --- a/tests/test_taylor.py +++ b/tests/test_taylor.py @@ -6,9 +6,7 @@ from geocat.viz.taylor import TaylorDiagram -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_model_set(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') @@ -21,9 +19,7 @@ def test_add_model_set(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_legend(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') @@ -50,9 +46,7 @@ def test_add_legend(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_bias_legend(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') @@ -72,9 +66,7 @@ def test_add_bias_legend(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_model_name(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') @@ -94,9 +86,7 @@ def test_add_model_name(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_corr_grid(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') @@ -116,9 +106,7 @@ def test_add_corr_grid(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_contours(): fig = plt.figure(figsize=(10, 10)) taylor = TaylorDiagram(fig=fig, label='REF') diff --git a/tests/test_util.py b/tests/test_util.py index d43f524..9346eb1 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -13,9 +13,7 @@ from geocat.viz.util import set_tick_direction_spine_visibility, add_lat_lon_gridlines, add_right_hand_axis, add_height_from_pressure_axis, add_lat_lon_ticklabels, add_major_minor_ticks, set_titles_and_labels, set_axes_limits_and_ticks, truncate_colormap, xr_add_cyclic_longitudes, set_map_boundary, find_local_extrema, plot_contour_labels, plot_extrema_labels, set_vector_density, get_skewt_vars -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_set_tick_direction_spine_visibility(): fig, ax = plt.subplots(figsize=(6, 6)) @@ -26,9 +24,7 @@ def test_set_tick_direction_spine_visibility(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_lat_lon_gridlines(): fig = plt.figure(figsize=(10, 10)) @@ -44,9 +40,7 @@ def test_add_lat_lon_gridlines(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_right_hand_axis(): fig = plt.figure(figsize=(9, 10)) ax1 = plt.gca() @@ -60,9 +54,7 @@ def test_add_right_hand_axis(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_height_from_pressure_axis(): fig = plt.figure(figsize=(8, 8)) ax = plt.axes() @@ -73,9 +65,7 @@ def test_add_height_from_pressure_axis(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_lat_lon_ticklabels(): fig = plt.figure(figsize=(12, 6)) @@ -87,9 +77,7 @@ def test_add_lat_lon_ticklabels(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_add_major_minor_ticks(): fig = plt.figure(figsize=(12, 6)) ax = plt.axes() @@ -101,9 +89,7 @@ def test_add_major_minor_ticks(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_set_titles_and_labels(): fig = fig, ax = plt.subplots() @@ -117,9 +103,7 @@ def test_set_titles_and_labels(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_set_axes_limits_and_ticks(): fig = fig, ax = plt.subplots() @@ -169,9 +153,7 @@ def test_xr_add_cyclic_longitudes_length(): assert len(U.lon) == len(cyclic_lon) -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_xr_add_cyclic_longitudes(): ds = xr.open_dataset(gdf.get("netcdf_files/slp.1963.nc"), decode_times=False) @@ -187,14 +169,11 @@ def test_xr_add_cyclic_longitudes(): p = wrap_pressure.plot.contour(ax=ax, transform=ccrs.PlateCarree(), linewidths=0.5, - cmap='black', add_labels=False) return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_set_map_boundary(): fig = plt.figure(figsize=(8, 8)) ax = plt.axes(projection=ccrs.NorthPolarStereo()) @@ -216,9 +195,7 @@ def test_find_local_extrema(): assert lmin == (2, 2) -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_plot_contour_labels(): ds = xr.open_dataset(gdf.get("netcdf_files/slp.1963.nc"), decode_times=False) @@ -233,7 +210,6 @@ def test_plot_contour_labels(): p = pressure.plot.contour(ax=ax, transform=ccrs.PlateCarree(), linewidths=0.5, - cmap='black', add_labels=False) contour_label_locations = [ @@ -250,9 +226,7 @@ def test_plot_contour_labels(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_plot_extrema_labels(): ds = xr.open_dataset(gdf.get("netcdf_files/slp.1963.nc"), decode_times=False) @@ -274,9 +248,7 @@ def test_plot_extrema_labels(): return fig -@pytest.mark.mpl_image_compare(tolerance=0.02, - remove_text=True, - style='default') +@pytest.mark.mpl_image_compare(tolerance=2, remove_text=True, style='default') def test_set_vector_density(): file_in = xr.open_dataset(gdf.get("netcdf_files/uv300.nc")) ds = file_in.isel(time=1, lon=slice(0, -1, 3), lat=slice(1, -1, 3))