Skip to content

Commit

Permalink
Merge branch 'NCAR:main' into issue258
Browse files Browse the repository at this point in the history
  • Loading branch information
kafitzgerald authored Dec 9, 2024
2 parents 79bfa22 + 42f6fc3 commit 0ba377b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: tests
run: |
python -m pytest
python -m pytest --mpl
link-check:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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
^^^^^^^
Expand Down
Binary file modified tests/baseline/test_plot_contour_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline/test_xr_add_cyclic_longitudes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 6 additions & 18 deletions tests/test_taylor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
54 changes: 13 additions & 41 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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))

Expand All @@ -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()
Expand All @@ -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()

Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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())
Expand All @@ -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)
Expand All @@ -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 = [
Expand All @@ -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)
Expand All @@ -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))
Expand Down

0 comments on commit 0ba377b

Please sign in to comment.