Backport fix for NumPy 1.21.

This commit is contained in:
Elliott Sales de Andrade 2021-08-09 20:26:55 -04:00
parent bb0eaa7b22
commit cbe4b20013
6 changed files with 78 additions and 4 deletions

View File

@ -1,7 +1,7 @@
From 6277ea0c008b02cd2abe017d041b43a35a407c6c 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>
---

View File

@ -1,7 +1,7 @@
From 322fe366ece11ae948c7f6ba0191f7dbc5db444b 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>
---

View File

@ -1,7 +1,7 @@
From d807e4e108073ee0fbda02340b206bf3766d9c7c 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>
---

View File

@ -1,7 +1,7 @@
From ea96e5684af98e28e704dc26f12b793c6032ada6 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 4 Jun 2021 03:20:38 -0400
Subject: [PATCH 4/4] Use new style for test_text_urls_tex.
Subject: [PATCH 4/5] Use new style for test_text_urls_tex.
This test does not depend on the font style, just that the annotation
appears over it. Switching to mpl20 style stops using Helvetica, and

View File

@ -0,0 +1,70 @@
From 982f5255e5da9c5023ca9997aff78c86eb0e8000 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Thu, 24 Jun 2021 01:45:04 -0400
Subject: [PATCH 5/5] Backport PR #20488: FIX: Include 0 when checking lognorm
vmin
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
lib/matplotlib/image.py | 6 +++---
lib/matplotlib/tests/test_image.py | 19 ++++++++++---------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py
index 98e2b5eb79..efa50758da 100644
--- a/lib/matplotlib/image.py
+++ b/lib/matplotlib/image.py
@@ -534,9 +534,9 @@ class _ImageBase(martist.Artist, cm.ScalarMappable):
# we have re-set the vmin/vmax to account for small errors
# that may have moved input values in/out of range
s_vmin, s_vmax = vrange
- if isinstance(self.norm, mcolors.LogNorm):
- if s_vmin < 0:
- s_vmin = max(s_vmin, np.finfo(scaled_dtype).eps)
+ if isinstance(self.norm, mcolors.LogNorm) and s_vmin <= 0:
+ # Don't give 0 or negative values to LogNorm
+ s_vmin = np.finfo(scaled_dtype).eps
with cbook._setattr_cm(self.norm,
vmin=s_vmin,
vmax=s_vmax,
diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py
index 9657968de7..38182f5a8a 100644
--- a/lib/matplotlib/tests/test_image.py
+++ b/lib/matplotlib/tests/test_image.py
@@ -1213,23 +1213,24 @@ def test_imshow_quantitynd():
fig.canvas.draw()
+@pytest.mark.parametrize('x', [-1, 1])
@check_figures_equal(extensions=['png'])
-def test_huge_range_log(fig_test, fig_ref):
- data = np.full((5, 5), -1, dtype=np.float64)
+def test_huge_range_log(fig_test, fig_ref, x):
+ # parametrize over bad lognorm -1 values and large range 1 -> 1e20
+ data = np.full((5, 5), x, dtype=np.float64)
data[0:2, :] = 1E20
ax = fig_test.subplots()
- im = ax.imshow(data, norm=colors.LogNorm(vmin=100, vmax=data.max()),
- interpolation='nearest', cmap='viridis')
+ ax.imshow(data, norm=colors.LogNorm(vmin=1, vmax=data.max()),
+ interpolation='nearest', cmap='viridis')
- data = np.full((5, 5), -1, dtype=np.float64)
+ data = np.full((5, 5), x, dtype=np.float64)
data[0:2, :] = 1000
- cmap = copy(plt.get_cmap('viridis'))
- cmap.set_under('w')
ax = fig_ref.subplots()
- im = ax.imshow(data, norm=colors.Normalize(vmin=100, vmax=data.max()),
- interpolation='nearest', cmap=cmap)
+ cmap = plt.get_cmap('viridis').with_extremes(under='w')
+ ax.imshow(data, norm=colors.Normalize(vmin=1, vmax=data.max()),
+ interpolation='nearest', cmap=cmap)
@check_figures_equal()
--
2.31.1

View File

@ -69,6 +69,8 @@ Patch1002: 0002-Set-FreeType-version-to-%{ftver}-and-update-tolerances.patc
# Workarounds for problems with texlive 2021 (#1965547)
Patch1003: 0003-Slightly-increase-tolerance-on-rcupdate-test.patch
Patch1004: 0004-Use-new-style-for-test_text_urls_tex.patch
# https://github.com/matplotlib/matplotlib/pull/20488
Patch1005: 0005-Backport-PR-20488-FIX-Include-0-when-checking-lognor.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -326,6 +328,7 @@ cp -p %{SOURCE1} setup.cfg
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
%build
@ -471,6 +474,7 @@ PYTHONDONTWRITEBYTECODE=1 \
%changelog
* Mon Aug 09 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 3.4.2-5
- Update test images for FreeType 2.11.0
- Backport patch for NumPy 1.21
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild