Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b965c4d

Browse files
authored
Merge pull request #15168 from tacaswell/mnt_py38_npbool_warnings
MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning
2 parents b09d17a + 3c93e41 commit b965c4d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
32133213
reverse = left > right
32143214
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
32153215
left, right = self.xaxis.limit_range_for_scale(left, right)
3216-
left, right = sorted([left, right], reverse=reverse)
3216+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
3217+
left, right = sorted([left, right], reverse=bool(reverse))
32173218

32183219
self._viewLim.intervalx = (left, right)
32193220
if auto is not None:
@@ -3597,7 +3598,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
35973598
reverse = bottom > top
35983599
bottom, top = self.yaxis.get_major_locator().nonsingular(bottom, top)
35993600
bottom, top = self.yaxis.limit_range_for_scale(bottom, top)
3600-
bottom, top = sorted([bottom, top], reverse=reverse)
3601+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
3602+
bottom, top = sorted([bottom, top], reverse=bool(reverse))
36013603

36023604
self._viewLim.intervaly = (bottom, top)
36033605
if auto is not None:

lib/matplotlib/axis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,8 @@ def get_minpos(self):
21692169
def set_inverted(self, inverted):
21702170
# docstring inherited
21712171
a, b = self.get_view_interval()
2172-
self.axes.set_xlim(sorted((a, b), reverse=inverted), auto=None)
2172+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
2173+
self.axes.set_xlim(sorted((a, b), reverse=bool(inverted)), auto=None)
21732174

21742175
def set_default_intervals(self):
21752176
# docstring inherited
@@ -2468,7 +2469,8 @@ def get_minpos(self):
24682469
def set_inverted(self, inverted):
24692470
# docstring inherited
24702471
a, b = self.get_view_interval()
2471-
self.axes.set_ylim(sorted((a, b), reverse=inverted), auto=None)
2472+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
2473+
self.axes.set_ylim(sorted((a, b), reverse=bool(inverted)), auto=None)
24722474

24732475
def set_default_intervals(self):
24742476
# docstring inherited

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False,
619619
reverse = left > right
620620
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
621621
left, right = self.xaxis.limit_range_for_scale(left, right)
622-
left, right = sorted([left, right], reverse=reverse)
622+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
623+
left, right = sorted([left, right], reverse=bool(reverse))
623624
self.xy_viewLim.intervalx = (left, right)
624625

625626
if auto is not None:

0 commit comments

Comments
 (0)