Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08a2502

Browse files
committed
Kill _string_to_bool.
1 parent 04aea74 commit 08a2502

File tree

6 files changed

+15
-35
lines changed

6 files changed

+15
-35
lines changed

doc/api/next_api_changes/2018-09-18-AL-removals.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ The following deprecated APIs were removed:
1919
``GridSpecFromSubplotSpec.get_subplot_params``,
2020
- svgfont support (in :rc:`svg.fonttype`),
2121
- passing 'box-forced' to `axes.Axes.set_adjustable`,
22+
- support for the strings 'on'/'true'/'off'/'false' to mean True/False (the
23+
following functions are affected: `Axes.grid`, `Axes3D.grid`,
24+
`Axis.set_tick_params`, `pyplot.box`),

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
import matplotlib as mpl
1212
from matplotlib import cbook, rcParams
13-
from matplotlib.cbook import (
14-
_OrderedSet, _check_1d, _string_to_bool, index_of, get_label)
13+
from matplotlib.cbook import _OrderedSet, _check_1d, index_of, get_label
1514
from matplotlib import docstring
1615
import matplotlib.colors as mcolors
1716
import matplotlib.lines as mlines
@@ -2736,9 +2735,6 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
27362735
"""
27372736
if len(kwargs):
27382737
b = True
2739-
elif b is not None:
2740-
b = _string_to_bool(b)
2741-
27422738
if axis not in ['x', 'y', 'both']:
27432739
raise ValueError("The argument 'axis' must be one of 'x', 'y' or "
27442740
"'both'.")

lib/matplotlib/axis.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from matplotlib import rcParams
1111
import matplotlib.artist as martist
1212
import matplotlib.cbook as cbook
13-
from matplotlib.cbook import _string_to_bool
1413
import matplotlib.font_manager as font_manager
1514
import matplotlib.lines as mlines
1615
import matplotlib.scale as mscale
@@ -843,8 +842,7 @@ def set_tick_params(self, which='major', reset=False, **kw):
843842

844843
@staticmethod
845844
def _translate_tick_kw(kw):
846-
# The following lists may be moved to a more
847-
# accessible location.
845+
# The following lists may be moved to a more accessible location.
848846
kwkeys = ['size', 'width', 'color', 'tickdir', 'pad',
849847
'labelsize', 'labelcolor', 'zorder', 'gridOn',
850848
'tick1On', 'tick2On', 'label1On', 'label2On',
@@ -859,21 +857,21 @@ def _translate_tick_kw(kw):
859857
if 'rotation' in kw:
860858
kwtrans['labelrotation'] = kw.pop('rotation')
861859
if 'left' in kw:
862-
kwtrans['tick1On'] = _string_to_bool(kw.pop('left'))
860+
kwtrans['tick1On'] = kw.pop('left')
863861
if 'bottom' in kw:
864-
kwtrans['tick1On'] = _string_to_bool(kw.pop('bottom'))
862+
kwtrans['tick1On'] = kw.pop('bottom')
865863
if 'right' in kw:
866-
kwtrans['tick2On'] = _string_to_bool(kw.pop('right'))
864+
kwtrans['tick2On'] = kw.pop('right')
867865
if 'top' in kw:
868-
kwtrans['tick2On'] = _string_to_bool(kw.pop('top'))
866+
kwtrans['tick2On'] = kw.pop('top')
869867
if 'labelleft' in kw:
870-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelleft'))
868+
kwtrans['label1On'] = kw.pop('labelleft')
871869
if 'labelbottom' in kw:
872-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelbottom'))
870+
kwtrans['label1On'] = kw.pop('labelbottom')
873871
if 'labelright' in kw:
874-
kwtrans['label2On'] = _string_to_bool(kw.pop('labelright'))
872+
kwtrans['label2On'] = kw.pop('labelright')
875873
if 'labeltop' in kw:
876-
kwtrans['label2On'] = _string_to_bool(kw.pop('labeltop'))
874+
kwtrans['label2On'] = kw.pop('labeltop')
877875
if 'colors' in kw:
878876
c = kw.pop('colors')
879877
kwtrans['color'] = c

lib/matplotlib/cbook/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -453,21 +453,6 @@ def is_scalar_or_string(val):
453453
return isinstance(val, str) or not np.iterable(val)
454454

455455

456-
def _string_to_bool(s):
457-
"""Parses the string argument as a boolean"""
458-
if not isinstance(s, str):
459-
return bool(s)
460-
warn_deprecated("2.2", message="Passing one of 'on', 'true', 'off', "
461-
"'false' as a boolean is deprecated; use an actual "
462-
"boolean (True/False) instead.")
463-
if s.lower() in ['on', 'true']:
464-
return True
465-
if s.lower() in ['off', 'false']:
466-
return False
467-
raise ValueError('String "%s" must be one of: '
468-
'"on", "off", "true", or "false"' % s)
469-
470-
471456
def get_sample_data(fname, asfileobj=True):
472457
"""
473458
Return a sample data file. *fname* is a path relative to the

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
import matplotlib.image
3434
from matplotlib import rcsetup, style
3535
from matplotlib import _pylab_helpers, interactive
36-
from matplotlib.cbook import (
37-
dedent, deprecated, silent_list, warn_deprecated, _string_to_bool)
3836
from matplotlib import cbook
37+
from matplotlib.cbook import dedent, deprecated, silent_list, warn_deprecated
3938
from matplotlib import docstring
4039
from matplotlib.backend_bases import FigureCanvasBase
4140
from matplotlib.figure import Figure, figaspect
@@ -1361,7 +1360,6 @@ def box(on=None):
13611360
ax = gca()
13621361
if on is None:
13631362
on = not ax.get_frame_on()
1364-
on = _string_to_bool(on)
13651363
ax.set_frame_on(on)
13661364

13671365
## Axis ##

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ def grid(self, b=True, **kwargs):
13001300
# TODO: Operate on each axes separately
13011301
if len(kwargs):
13021302
b = True
1303-
self._draw_grid = cbook._string_to_bool(b)
1303+
self._draw_grid = b
13041304
self.stale = True
13051305

13061306
def ticklabel_format(

0 commit comments

Comments
 (0)