Skip to content

Some more usage of _check_in_list. #13833

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
Apr 2, 2019
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
17 changes: 6 additions & 11 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6573,17 +6573,12 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
if bins is None:
bins = rcParams['hist.bins']

# Validate string inputs here so we don't have to clutter
# subsequent code.
if histtype not in ['bar', 'barstacked', 'step', 'stepfilled']:
raise ValueError("histtype %s is not recognized" % histtype)

if align not in ['left', 'mid', 'right']:
raise ValueError("align kwarg %s is not recognized" % align)

if orientation not in ['horizontal', 'vertical']:
raise ValueError(
"orientation kwarg %s is not recognized" % orientation)
# Validate string inputs here to avoid cluttering subsequent code.
cbook._check_in_list(['bar', 'barstacked', 'step', 'stepfilled'],
histtype=histtype)
cbook._check_in_list(['left', 'mid', 'right'], align=align)
cbook._check_in_list(['horizontal', 'vertical'],
orientation=orientation)

if histtype == 'barstacked' and not stacked:
stacked = True
Expand Down
14 changes: 4 additions & 10 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,13 @@ def get_cmap(name=None, lut=None):
"""
if name is None:
name = mpl.rcParams['image.cmap']

if isinstance(name, colors.Colormap):
return name

if name in cmap_d:
if lut is None:
return cmap_d[name]
else:
return cmap_d[name]._resample(lut)
cbook._check_in_list(sorted(cmap_d), name=name)
if lut is None:
return cmap_d[name]
else:
raise ValueError(
"Colormap %s is not recognized. Possible values are: %s"
% (name, ', '.join(sorted(cmap_d))))
return cmap_d[name]._resample(lut)


class ScalarMappable(object):
Expand Down