From a83ba4a2476d620d66f5c00c46da242f8d2495cf Mon Sep 17 00:00:00 2001 From: Ryan May Date: Tue, 31 Oct 2023 16:32:45 -0600 Subject: [PATCH 1/3] MNT: Update some image test thresholds This gets the suite passing on my M2. There are a couple contour tests that need a higher threshold for some reason, but manual inspection confirms tests are behaving as expected. --- tests/plots/test_declarative.py | 16 ++++++++-------- tests/plots/test_patheffects.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/plots/test_declarative.py b/tests/plots/test_declarative.py index aa4e871cd45..94caf0eae8f 100644 --- a/tests/plots/test_declarative.py +++ b/tests/plots/test_declarative.py @@ -91,7 +91,7 @@ def test_declarative_four_dims_error(): pc.draw() -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.092) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.093) @needs_cartopy def test_declarative_contour(): """Test making a contour plot.""" @@ -119,7 +119,7 @@ def test_declarative_contour(): return pc.figure -@pytest.mark.mpl_image_compare(remove_text=False, tolerance=0.093) +@pytest.mark.mpl_image_compare(remove_text=False, tolerance=0.094) @needs_cartopy def test_declarative_titles(): """Test making a contour plot with multiple titles.""" @@ -150,7 +150,7 @@ def test_declarative_titles(): return pc.figure -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.072) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.098) @needs_cartopy def test_declarative_smooth_contour(): """Test making a contour plot using smooth_contour.""" @@ -307,7 +307,7 @@ def test_declarative_smooth_field(): return pc.figure -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.708) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.828) @needs_cartopy def test_declarative_contour_cam(): """Test making a contour plot with CAM data.""" @@ -335,7 +335,7 @@ def test_declarative_contour_cam(): @pytest.mark.mpl_image_compare(remove_text=True, - tolerance=3.71 if mpl_version_before('3.8') else 0.026) + tolerance=3.71 if mpl_version_before('3.8') else 0.74) @needs_cartopy def test_declarative_contour_options(): """Test making a contour plot.""" @@ -396,7 +396,7 @@ def test_declarative_layers_plot_options(): @pytest.mark.mpl_image_compare(remove_text=True, - tolerance=2.74 if mpl_version_before('3.8') else 0.014) + tolerance=2.74 if mpl_version_before('3.8') else 1.91) @needs_cartopy def test_declarative_contour_convert_units(): """Test making a contour plot.""" @@ -426,7 +426,7 @@ def test_declarative_contour_convert_units(): return pc.figure -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.247) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.276) @needs_cartopy def test_declarative_events(): """Test that resetting traitlets properly propagates.""" @@ -568,7 +568,7 @@ def test_no_field_error_barbs(): barbs.draw() -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.378) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.381) def test_projection_object(ccrs, cfeature): """Test that we can pass a custom map projection.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) diff --git a/tests/plots/test_patheffects.py b/tests/plots/test_patheffects.py index 6763473cd24..d1af81a8b35 100644 --- a/tests/plots/test_patheffects.py +++ b/tests/plots/test_patheffects.py @@ -15,7 +15,7 @@ StationaryFrontolysis, WarmFront, WarmFrontogenesis, WarmFrontolysis) -@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.01) def test_fronts(): """Basic test of plotting fronts using path effects.""" x = np.linspace(0, 80, 5) From f6773c23d7ceca43f6420d1f961a79653c34767c Mon Sep 17 00:00:00 2001 From: Ryan May Date: Wed, 1 Nov 2023 11:18:06 -0600 Subject: [PATCH 2/3] MNT: Mark test_moist_lapse_failure as xfail on mac arm64 Apparently this problematic test fails here too. --- tests/calc/test_thermo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/calc/test_thermo.py b/tests/calc/test_thermo.py index 59877bb9851..6a7017eed13 100644 --- a/tests/calc/test_thermo.py +++ b/tests/calc/test_thermo.py @@ -200,6 +200,7 @@ def test_moist_lapse_starting_points(start, direction): @pytest.mark.xfail(platform.machine() == 'aarch64', reason='ValueError is not raised on aarch64') +@pytest.mark.xfail(platform.machine() == 'arm64', reason='ValueError is not raised on Mac M2') @pytest.mark.xfail(sys.platform == 'win32', reason='solve_ivp() does not error on Windows') @pytest.mark.xfail(packaging.version.parse(scipy.__version__) < packaging.version.parse('1.7'), reason='solve_ivp() does not error on Scipy < 1.7') From 3056c18fa5765c3433b0071006bc687e348768f0 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Wed, 1 Nov 2023 11:52:24 -0600 Subject: [PATCH 3/3] MNT: Avoid order-dependence in test_find_nn_triangles_point() --- tests/interpolate/test_geometry.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/interpolate/test_geometry.py b/tests/interpolate/test_geometry.py index 8dd4921107d..0ca0bc4ff87 100644 --- a/tests/interpolate/test_geometry.py +++ b/tests/interpolate/test_geometry.py @@ -178,11 +178,14 @@ def test_find_nn_triangles_point(): tri = Delaunay(pts) tri_match = tri.find_simplex([4.5, 4.5]) - nn = find_nn_triangles_point(tri, tri_match, [4.5, 4.5]) - - # Can't rely on simplex indices, so need to check point indices - truth = {(45, 55, 44), (55, 54, 44)} - assert {tuple(verts) for verts in tri.simplices[nn]} == truth + nn = find_nn_triangles_point(tri, tri_match, (4.5, 4.5)) + + # Can't rely on simplex indices or the order of points that define them, + # so need to be a bit more involved to check + truth = [{45, 55, 44}, {55, 54, 44}] + found = [set(verts) for verts in tri.simplices[nn]] + for s in truth: + assert s in found def test_find_local_boundary():