Backport bool deprecation warning fix.

This commit is contained in:
Elliott Sales de Andrade 2019-09-06 21:12:35 -04:00
parent e8c7e2c6d2
commit c533793071
2 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,68 @@
commit 4651a1253ca5dc597550c5cd746f30dabee770bc
Author: Jody Klymak <jklymak@gmail.com>
Date: Wed Sep 4 10:48:01 2019 -0700
Backport PR #15168: MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning
diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py
index ff5aaf032..c2a4d2f42 100644
--- a/lib/matplotlib/axes/_base.py
+++ b/lib/matplotlib/axes/_base.py
@@ -3267,7 +3267,8 @@ class _AxesBase(martist.Artist):
reverse = left > right
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
left, right = self.xaxis.limit_range_for_scale(left, right)
- left, right = sorted([left, right], reverse=reverse)
+ # cast to bool to avoid bad interaction between python 3.8 and np.bool_
+ left, right = sorted([left, right], reverse=bool(reverse))
self.viewLim.intervalx = (left, right)
if auto is not None:
@@ -3649,7 +3650,8 @@ class _AxesBase(martist.Artist):
reverse = bottom > top
bottom, top = self.yaxis.get_major_locator().nonsingular(bottom, top)
bottom, top = self.yaxis.limit_range_for_scale(bottom, top)
- bottom, top = sorted([bottom, top], reverse=reverse)
+ # cast to bool to avoid bad interaction between python 3.8 and np.bool_
+ bottom, top = sorted([bottom, top], reverse=bool(reverse))
self.viewLim.intervaly = (bottom, top)
if auto is not None:
diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py
index a4cdffc55..e23b5748c 100644
--- a/lib/matplotlib/axis.py
+++ b/lib/matplotlib/axis.py
@@ -2156,7 +2156,8 @@ class XAxis(Axis):
def set_inverted(self, inverted):
# docstring inherited
a, b = self.get_view_interval()
- self.axes.set_xlim(sorted((a, b), reverse=inverted), auto=None)
+ # cast to bool to avoid bad interaction between python 3.8 and np.bool_
+ self.axes.set_xlim(sorted((a, b), reverse=bool(inverted)), auto=None)
def set_default_intervals(self):
# docstring inherited
@@ -2463,7 +2464,8 @@ class YAxis(Axis):
def set_inverted(self, inverted):
# docstring inherited
a, b = self.get_view_interval()
- self.axes.set_ylim(sorted((a, b), reverse=inverted), auto=None)
+ # cast to bool to avoid bad interaction between python 3.8 and np.bool_
+ self.axes.set_ylim(sorted((a, b), reverse=bool(inverted)), auto=None)
def set_default_intervals(self):
# docstring inherited
diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py
index 4202be9a1..047234b36 100644
--- a/lib/mpl_toolkits/mplot3d/axes3d.py
+++ b/lib/mpl_toolkits/mplot3d/axes3d.py
@@ -626,7 +626,8 @@ class Axes3D(Axes):
reverse = left > right
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
left, right = self.xaxis.limit_range_for_scale(left, right)
- left, right = sorted([left, right], reverse=reverse)
+ # cast to bool to avoid bad interaction between python 3.8 and np.bool_
+ left, right = sorted([left, right], reverse=bool(reverse))
self.xy_viewLim.intervalx = (left, right)
if auto is not None:

View File

@ -44,7 +44,7 @@
Name: python-matplotlib
Version: 3.1.1
Release: 1%{?rctag:.%{rctag}}%{?dist}.1
Release: 2%{?rctag:.%{rctag}}%{?dist}
Summary: Python 2D plotting library
# qt4_editor backend is MIT
License: Python and MIT
@ -63,6 +63,10 @@ Patch0002: 0001-Use-packaged-jquery-and-jquery-ui.patch
# https://github.com/matplotlib/matplotlib/pull/14901
Patch0003: 1230e83b6793e5ccda8543f3584eb8bc2dc657e2.patch
# Fix np.bool_ -> bool deprecation warnings on Python 3.8.
# https://github.com/matplotlib/matplotlib/pull/15168
Patch0004: 4651a1253ca5dc597550c5cd746f30dabee770bc.patch
# Fedora-specific patches; see:
# https://github.com/fedora-python/matplotlib/tree/fedora-patches
# https://github.com/fedora-python/matplotlib/tree/fedora-patches-non-x86
@ -264,6 +268,8 @@ Requires: python3-matplotlib%{?_isa} = %{version}-%{release}
%patch0003 -p1
%patch0004 -p1
# Fedora-specific patches follow:
%patch1001 -p1
# Updated test images for new FreeType.
@ -451,6 +457,9 @@ PYTHONDONTWRITEBYTECODE=1 \
%changelog
* Fri Sep 06 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 3.1.1-2
- Backport bool deprecation fix for Python 3.8
* Sun Aug 18 2019 Miro Hrončok <mhroncok@redhat.com> - 3.1.1-1.1
- Rebuilt for Python 3.8