Skip to content

Use cbook methods for string checking #26744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,7 @@ def _auto_sized_delimiter(self, front: str,
depth = max([x.depth for x in middle if not isinstance(x, str)])
factor = None
for idx, el in enumerate(middle):
if isinstance(el, str) and el == '\\middle':
if el == r'\middle':
c = T.cast(str, middle[idx + 1]) # Should be one of p.delims.
if c != '.':
middle[idx + 1] = AutoHeightChar(
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import numpy as np

import matplotlib as mpl
from matplotlib import _api, _docstring, colors, offsetbox
from matplotlib import _api, _docstring, cbook, colors, offsetbox
from matplotlib.artist import Artist, allow_rasterization
from matplotlib.cbook import silent_list
from matplotlib.font_manager import FontProperties
Expand Down Expand Up @@ -622,7 +622,7 @@ def __init__(
break
except AttributeError:
pass
elif isinstance(labelcolor, str) and labelcolor == 'none':
elif cbook._str_equal(labelcolor, 'none'):
for text in self.texts:
text.set_color(labelcolor)
elif np.iterable(labelcolor):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _make_type_validator(cls, *, allow_none=False):

def validator(s):
if (allow_none and
(s is None or isinstance(s, str) and s.lower() == "none")):
(s is None or cbook._str_lower_equal(s, "none"))):
return None
if cls is str and not isinstance(s, str):
raise ValueError(f'Could not convert {s!r} to str')
Expand Down Expand Up @@ -615,7 +615,7 @@ def _validate_minor_tick_ndivs(n):
two major ticks.
"""

if isinstance(n, str) and n.lower() == 'auto':
if cbook._str_lower_equal(n, 'auto'):
return n
try:
n = _validate_int_greaterequal0(n)
Expand Down