Backport fix to pcolormesh snap argument

This commit is contained in:
Elliott Sales de Andrade
2021-10-09 00:03:59 -04:00
parent d965724300
commit 1b0f98b373
6 changed files with 73 additions and 4 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
From 4039d6d10c679aa5c9a3268fbea663e05acf50d3 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 27 Sep 2017 19:35:59 -0400
Subject: [PATCH 1/4] matplotlibrc path search fix
Subject: [PATCH 1/5] matplotlibrc path search fix
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
@@ -1,7 +1,7 @@
From 0779db3fa70c58e88e048bec9b738ae02fccaead Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 14 Feb 2020 06:05:42 -0500
Subject: [PATCH 2/4] Set FreeType version to 2.11.0 and update tolerances.
Subject: [PATCH 2/5] Set FreeType version to 2.11.0 and update tolerances.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
@@ -1,7 +1,7 @@
From af387ba8868b761273dc85b288196822ebba345c Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 4 Jun 2021 02:32:31 -0400
Subject: [PATCH 3/4] Slightly increase tolerance on rcupdate test.
Subject: [PATCH 3/5] Slightly increase tolerance on rcupdate test.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
@@ -1,7 +1,7 @@
From ce44fc4f778f3e7d781f5d812e86b10dff2ee1fc Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Tue, 24 Aug 2021 04:47:50 -0400
Subject: [PATCH 4/4] Increase a few test tolerances on some arches.
Subject: [PATCH 4/5] Increase a few test tolerances on some arches.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
@@ -0,0 +1,66 @@
From 4dabe86f04281c9ec307ecb2586f29f9c03b1257 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Tue, 5 Oct 2021 22:14:49 -0400
Subject: [PATCH 5/5] Fix snap argument to pcolormesh
If it's passed as a keyword argument, then it needs to be removed from
`kwargs`, or not passed again explicitly. Other handling of `snap` uses
`setdefault`, so do that here too.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
lib/matplotlib/axes/_axes.py | 5 +++--
lib/matplotlib/tests/test_axes.py | 7 ++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py
index 4eca2e6b0b..dcaadb8be3 100644
--- a/lib/matplotlib/axes/_axes.py
+++ b/lib/matplotlib/axes/_axes.py
@@ -6016,9 +6016,10 @@ default: :rc:`scatter.edgecolors`
# convert to one dimensional array
C = C.ravel()
- snap = kwargs.get('snap', rcParams['pcolormesh.snap'])
+ kwargs.setdefault('snap', rcParams['pcolormesh.snap'])
+
collection = mcoll.QuadMesh(
- coords, antialiased=antialiased, shading=shading, snap=snap,
+ coords, antialiased=antialiased, shading=shading,
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
collection._scale_norm(norm, vmin, vmax)
self._pcolor_grid_deprecation_helper()
diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py
index a5e678d048..935cd11c1e 100644
--- a/lib/matplotlib/tests/test_axes.py
+++ b/lib/matplotlib/tests/test_axes.py
@@ -1250,22 +1250,23 @@ def test_pcolorflaterror():
ax.pcolormesh(x, y, Z, shading='flat')
+@pytest.mark.parametrize('snap', [False, True])
@check_figures_equal(extensions=["png"])
-def test_pcolorauto(fig_test, fig_ref):
+def test_pcolorauto(fig_test, fig_ref, snap):
ax = fig_test.subplots()
x = np.arange(0, 10)
y = np.arange(0, 4)
np.random.seed(19680801)
Z = np.random.randn(3, 9)
# this is the same as flat; note that auto is default
- ax.pcolormesh(x, y, Z)
+ ax.pcolormesh(x, y, Z, snap=snap)
ax = fig_ref.subplots()
# specify the centers
x2 = x[:-1] + np.diff(x) / 2
y2 = y[:-1] + np.diff(y) / 2
# this is same as nearest:
- ax.pcolormesh(x2, y2, Z)
+ ax.pcolormesh(x2, y2, Z, snap=snap)
@image_comparison(['canonical'])
--
2.31.1
+3
View File
@@ -58,6 +58,8 @@ Patch1002: 0002-Set-FreeType-version-to-%{ftver}-and-update-tolerances.patc
# Work around for problems with texlive 2021 (#1965547)
Patch1003: 0003-Slightly-increase-tolerance-on-rcupdate-test.patch
Patch1004: 0004-Increase-a-few-test-tolerances-on-some-arches.patch
# https://github.com/matplotlib/matplotlib/pull/21293
Patch1005: 0005-Fix-snap-argument-to-pcolormesh.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@@ -282,6 +284,7 @@ cp -p %{SOURCE1} mplsetup.cfg
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
%generate_buildrequires