Skip to content

Commit 1191549

Browse files
authored
Merge pull request #15185 from meeseeksmachine/auto-backport-of-pr-15168-on-v3.1.x
Backport PR #15168 on branch v3.1.x (MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning)
2 parents ba89a16 + 4651a12 commit 1191549

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
@@ -3267,7 +3267,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
32673267
reverse = left > right
32683268
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
32693269
left, right = self.xaxis.limit_range_for_scale(left, right)
3270-
left, right = sorted([left, right], reverse=reverse)
3270+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
3271+
left, right = sorted([left, right], reverse=bool(reverse))
32713272

32723273
self.viewLim.intervalx = (left, right)
32733274
if auto is not None:
@@ -3649,7 +3650,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
36493650
reverse = bottom > top
36503651
bottom, top = self.yaxis.get_major_locator().nonsingular(bottom, top)
36513652
bottom, top = self.yaxis.limit_range_for_scale(bottom, top)
3652-
bottom, top = sorted([bottom, top], reverse=reverse)
3653+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
3654+
bottom, top = sorted([bottom, top], reverse=bool(reverse))
36533655

36543656
self.viewLim.intervaly = (bottom, top)
36553657
if auto is not None:

lib/matplotlib/axis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,8 @@ def get_minpos(self):
21562156
def set_inverted(self, inverted):
21572157
# docstring inherited
21582158
a, b = self.get_view_interval()
2159-
self.axes.set_xlim(sorted((a, b), reverse=inverted), auto=None)
2159+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
2160+
self.axes.set_xlim(sorted((a, b), reverse=bool(inverted)), auto=None)
21602161

21612162
def set_default_intervals(self):
21622163
# docstring inherited
@@ -2463,7 +2464,8 @@ def get_minpos(self):
24632464
def set_inverted(self, inverted):
24642465
# docstring inherited
24652466
a, b = self.get_view_interval()
2466-
self.axes.set_ylim(sorted((a, b), reverse=inverted), auto=None)
2467+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
2468+
self.axes.set_ylim(sorted((a, b), reverse=bool(inverted)), auto=None)
24672469

24682470
def set_default_intervals(self):
24692471
# docstring inherited

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False,
626626
reverse = left > right
627627
left, right = self.xaxis.get_major_locator().nonsingular(left, right)
628628
left, right = self.xaxis.limit_range_for_scale(left, right)
629-
left, right = sorted([left, right], reverse=reverse)
629+
# cast to bool to avoid bad interaction between python 3.8 and np.bool_
630+
left, right = sorted([left, right], reverse=bool(reverse))
630631
self.xy_viewLim.intervalx = (left, right)
631632

632633
if auto is not None:

0 commit comments

Comments
 (0)