Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7f6874

Browse filesBrowse files
committed
Merge pull request #2182 from NelleV/axes_module_plotting
[Sprint] ENH Move _string_to_bool from axes._base to cbook
2 parents 4b588a7 + d32e2ab commit e7f6874
Copy full SHA for e7f6874

File tree

Expand file treeCollapse file tree

6 files changed

+25
-21
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+25
-21
lines changed

‎lib/matplotlib/axes/__init__.py

Copy file name to clipboard
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
from matplotlib.axes._subplots import *
22
from matplotlib.axes._axes import *
3-
from matplotlib.axes._base import _string_to_bool

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
rcParams = matplotlib.rcParams
1111

1212
import matplotlib.cbook as cbook
13+
from matplotlib.cbook import _string_to_bool
1314
import matplotlib.collections as mcoll
1415
import matplotlib.colors as mcolors
1516
import matplotlib.contour as mcontour

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
rcParams = matplotlib.rcParams
1111

1212
from matplotlib import cbook
13+
from matplotlib.cbook import _string_to_bool
1314
from matplotlib import docstring
1415
import matplotlib.colors as mcolors
1516
import matplotlib.lines as mlines
@@ -33,16 +34,6 @@
3334
is_sequence_of_strings = cbook.is_sequence_of_strings
3435

3536

36-
def _string_to_bool(s):
37-
if not is_string_like(s):
38-
return s
39-
if s == 'on':
40-
return True
41-
if s == 'off':
42-
return False
43-
raise ValueError("string argument must be either 'on' or 'off'")
44-
45-
4637
def _process_plot_format(fmt):
4738
"""
4839
Process a MATLAB style color/line style format string. Return a

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+20-8Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class MatplotlibDeprecationWarning(UserWarning):
4545
mplDeprecation = MatplotlibDeprecationWarning
4646

4747

48-
def _generate_deprecation_message(
49-
since, message='', name='', alternative='', pending=False,
50-
obj_type='attribute'):
48+
def _generate_deprecation_message(since, message='', name='',
49+
alternative='', pending=False,
50+
obj_type='attribute'):
5151

5252
if not message:
5353
altmessage = ''
@@ -464,9 +464,11 @@ class CallbackRegistry:
464464
"""
465465
def __init__(self, *args):
466466
if len(args):
467-
warn_deprecated('1.3', message=
468-
"CallbackRegistry no longer requires a list of callback "
469-
"types. Ignoring arguments. *args will be removed in 1.5")
467+
warn_deprecated(
468+
'1.3',
469+
message="CallbackRegistry no longer requires a list of "
470+
"callback types. Ignoring arguments. *args will "
471+
"be removed in 1.5")
470472
self.callbacks = dict()
471473
self._cid = 0
472474
self._func_cid_map = {}
@@ -750,6 +752,16 @@ def is_scalar_or_string(val):
750752
return is_string_like(val) or not iterable(val)
751753

752754

755+
def _string_to_bool(s):
756+
if not is_string_like(s):
757+
return s
758+
if s == 'on':
759+
return True
760+
if s == 'off':
761+
return False
762+
raise ValueError("string argument must be either 'on' or 'off'")
763+
764+
753765
def get_sample_data(fname, asfileobj=True):
754766
"""
755767
Return a sample data file. *fname* is a path relative to the
@@ -1724,8 +1736,8 @@ def simple_linear_interpolation(a, steps):
17241736

17251737
def recursive_remove(path):
17261738
if os.path.isdir(path):
1727-
for fname in glob.glob(os.path.join(path, '*')) + \
1728-
glob.glob(os.path.join(path, '.*')):
1739+
for fname in (glob.glob(os.path.join(path, '*')) +
1740+
glob.glob(os.path.join(path, '.*'))):
17291741
if os.path.isdir(fname):
17301742
recursive_remove(fname)
17311743
os.removedirs(fname)

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import matplotlib.colorbar
2525
from matplotlib import _pylab_helpers, interactive
2626
from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
27+
from matplotlib.cbook import _string_to_bool
2728
from matplotlib import docstring
2829
from matplotlib.backend_bases import FigureCanvasBase
2930
from matplotlib.figure import Figure, figaspect
@@ -35,7 +36,7 @@
3536
from matplotlib.rcsetup import interactive_bk as _interactive_bk
3637
from matplotlib.artist import getp, get, Artist
3738
from matplotlib.artist import setp as _setp
38-
from matplotlib.axes import Axes, Subplot, _string_to_bool
39+
from matplotlib.axes import Axes, Subplot
3940
from matplotlib.projections import PolarAxes
4041
from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
4142
from matplotlib.scale import get_scale_docs, get_scale_names

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ def grid(self, b=True, **kwargs):
12531253
# TODO: Operate on each axes separately
12541254
if len(kwargs) :
12551255
b = True
1256-
self._draw_grid = maxes._string_to_bool(b)
1256+
self._draw_grid = cbook._string_to_bool(b)
12571257

12581258
def ticklabel_format(self, **kwargs) :
12591259
"""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.