From a921be8273beae515be680e195af50abb2334e07 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 18 Jun 2019 08:00:46 +0200 Subject: [PATCH] Rewrite an argument check to _check_getitem --- lib/matplotlib/axes/_base.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index ca45ee42dbb2..c8b2c355b567 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2811,21 +2811,15 @@ def ticklabel_format(self, *, axis='both', style='', scilimits=None, m + n + 1 # check that both are numbers except (ValueError, TypeError): raise ValueError("scilimits must be a sequence of 2 integers") - if style[:3] == 'sci': - sb = True - elif style == 'plain': - sb = False - elif style == '': - sb = None - else: - raise ValueError("%s is not a valid style value") + STYLES = {'sci': True, 'scientific': True, 'plain': False, '': None} + is_sci_style = cbook._check_getitem(STYLES, style=style) axis_map = {**{k: [v] for k, v in self._get_axis_map().items()}, 'both': self._get_axis_list()} axises = cbook._check_getitem(axis_map, axis=axis) try: for axis in axises: - if sb is not None: - axis.major.formatter.set_scientific(sb) + if is_sci_style is not None: + axis.major.formatter.set_scientific(is_sci_style) if scilimits is not None: axis.major.formatter.set_powerlimits(scilimits) if useOffset is not None: