MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning · tacaswell/matplotlib@6df091f · GitHub
Skip to content

Commit 6df091f

Browse files
committed
MNT: explicitly cast np.bool_ -> bool to prevent deprecation warning
This is a workaround to https://bugs.python.org/issue37980 - np.bool raises a warning if you try to use it as an index (by warning in its `__index__` method - in py38 python/cpython#11952 python changes the code path used to convert `np.bool_` -> int for as it is used in `sorted` so it now goes through the `__index__` code path - this causes a bunch of spurious warnings to come out of Matplotlib.
1 parent b3fadcb commit 6df091f

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 2 deletions

lib/matplotlib/axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ 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+
self.axes.set_xlim(sorted((a, b), reverse=bool(inverted)), auto=None)
21732173

21742174
def set_default_intervals(self):
21752175
# docstring inherited
@@ -2468,7 +2468,7 @@ def get_minpos(self):
24682468
def set_inverted(self, inverted):
24692469
# docstring inherited
24702470
a, b = self.get_view_interval()
2471-
self.axes.set_ylim(sorted((a, b), reverse=inverted), auto=None)
2471+
self.axes.set_ylim(sorted((a, b), reverse=bool(inverted)), auto=None)
24722472

24732473
def set_default_intervals(self):
24742474
# docstring inherited

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)