Skip to content

Commit aef9fd4

Browse files
committed
Kill _string_to_bool.
1 parent deeded0 commit aef9fd4

File tree

6 files changed

+12
-34
lines changed

6 files changed

+12
-34
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ 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.

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import matplotlib
1313

1414
from matplotlib import cbook, rcParams
15-
from matplotlib.cbook import (
16-
_OrderedSet, _check_1d, _string_to_bool, index_of, get_label)
15+
from matplotlib.cbook import _OrderedSet, _check_1d, index_of, get_label
1716
from matplotlib import docstring
1817
import matplotlib.colors as mcolors
1918
import matplotlib.lines as mlines
@@ -2720,9 +2719,6 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
27202719
"""
27212720
if len(kwargs):
27222721
b = True
2723-
elif b is not None:
2724-
b = _string_to_bool(b)
2725-
27262722
if axis not in ['x', 'y', 'both']:
27272723
raise ValueError("The argument 'axis' must be one of 'x', 'y' or "
27282724
"'both'.")

lib/matplotlib/axis.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from matplotlib import rcParams
1212
import matplotlib.artist as artist
1313
import matplotlib.cbook as cbook
14-
from matplotlib.cbook import _string_to_bool
1514
import matplotlib.font_manager as font_manager
1615
import matplotlib.lines as mlines
1716
import matplotlib.patches as mpatches
@@ -878,22 +877,21 @@ def _translate_tick_kw(kw, to_init_kw=True):
878877
if 'rotation' in kw:
879878
kwtrans['labelrotation'] = kw.pop('rotation')
880879
if 'left' in kw:
881-
kwtrans['tick1On'] = _string_to_bool(kw.pop('left'))
880+
kwtrans['tick1On'] = kw.pop('left')
882881
if 'bottom' in kw:
883-
kwtrans['tick1On'] = _string_to_bool(kw.pop('bottom'))
882+
kwtrans['tick1On'] = kw.pop('bottom')
884883
if 'right' in kw:
885-
kwtrans['tick2On'] = _string_to_bool(kw.pop('right'))
884+
kwtrans['tick2On'] = kw.pop('right')
886885
if 'top' in kw:
887-
kwtrans['tick2On'] = _string_to_bool(kw.pop('top'))
888-
886+
kwtrans['tick2On'] = kw.pop('top')
889887
if 'labelleft' in kw:
890-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelleft'))
888+
kwtrans['label1On'] = kw.pop('labelleft')
891889
if 'labelbottom' in kw:
892-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelbottom'))
890+
kwtrans['label1On'] = kw.pop('labelbottom')
893891
if 'labelright' in kw:
894-
kwtrans['label2On'] = _string_to_bool(kw.pop('labelright'))
892+
kwtrans['label2On'] = kw.pop('labelright')
895893
if 'labeltop' in kw:
896-
kwtrans['label2On'] = _string_to_bool(kw.pop('labeltop'))
894+
kwtrans['label2On'] = kw.pop('labeltop')
897895
if 'colors' in kw:
898896
c = kw.pop('colors')
899897
kwtrans['color'] = c

lib/matplotlib/cbook/__init__.py

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

418418

419-
def _string_to_bool(s):
420-
"""Parses the string argument as a boolean"""
421-
if not isinstance(s, str):
422-
return bool(s)
423-
warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "
424-
"boolean is deprecated; use an actual boolean "
425-
"(True/False) instead.")
426-
if s.lower() in ['on', 'true']:
427-
return True
428-
if s.lower() in ['off', 'false']:
429-
return False
430-
raise ValueError('String "%s" must be one of: '
431-
'"on", "off", "true", or "false"' % s)
432-
433-
434419
def get_sample_data(fname, asfileobj=True):
435420
"""
436421
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,8 +33,7 @@
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)
36+
from matplotlib.cbook import dedent, deprecated, silent_list, warn_deprecated
3837
from matplotlib import docstring
3938
from matplotlib.backend_bases import FigureCanvasBase
4039
from matplotlib.figure import Figure, figaspect
@@ -1358,7 +1357,6 @@ def box(on=None):
13581357
ax = gca()
13591358
if on is None:
13601359
on = not ax.get_frame_on()
1361-
on = _string_to_bool(on)
13621360
ax.set_frame_on(on)
13631361

13641362
## 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy