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

[Sprint] ENH Move _string_to_bool from axes._base to cbook #2182

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
Jun 30, 2013
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
ENH Move _string_to_bool from axes._base to cbook
  • Loading branch information
NelleV committed Jun 29, 2013
commit d32e2ab37aeabab1a3ffdfd7da280bf7186fa372
1 change: 0 additions & 1 deletion 1 lib/matplotlib/axes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from matplotlib.axes._subplots import *
from matplotlib.axes._axes import *
from matplotlib.axes._base import _string_to_bool
1 change: 1 addition & 0 deletions 1 lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
rcParams = matplotlib.rcParams

import matplotlib.cbook as cbook
from matplotlib.cbook import _string_to_bool
import matplotlib.collections as mcoll
import matplotlib.colors as mcolors
import matplotlib.contour as mcontour
Expand Down
11 changes: 1 addition & 10 deletions 11 lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
rcParams = matplotlib.rcParams

from matplotlib import cbook
from matplotlib.cbook import _string_to_bool
from matplotlib import docstring
import matplotlib.colors as mcolors
import matplotlib.lines as mlines
Expand All @@ -33,16 +34,6 @@
is_sequence_of_strings = cbook.is_sequence_of_strings


def _string_to_bool(s):
if not is_string_like(s):
return s
if s == 'on':
return True
if s == 'off':
return False
raise ValueError("string argument must be either 'on' or 'off'")


def _process_plot_format(fmt):
"""
Process a MATLAB style color/line style format string. Return a
Expand Down
28 changes: 20 additions & 8 deletions 28 lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class MatplotlibDeprecationWarning(UserWarning):
mplDeprecation = MatplotlibDeprecationWarning


def _generate_deprecation_message(
since, message='', name='', alternative='', pending=False,
obj_type='attribute'):
def _generate_deprecation_message(since, message='', name='',
alternative='', pending=False,
obj_type='attribute'):

if not message:
altmessage = ''
Expand Down Expand Up @@ -464,9 +464,11 @@ class CallbackRegistry:
"""
def __init__(self, *args):
if len(args):
warn_deprecated('1.3', message=
"CallbackRegistry no longer requires a list of callback "
"types. Ignoring arguments. *args will be removed in 1.5")
warn_deprecated(
'1.3',
message="CallbackRegistry no longer requires a list of "
"callback types. Ignoring arguments. *args will "
"be removed in 1.5")
self.callbacks = dict()
self._cid = 0
self._func_cid_map = {}
Expand Down Expand Up @@ -750,6 +752,16 @@ def is_scalar_or_string(val):
return is_string_like(val) or not iterable(val)


def _string_to_bool(s):
if not is_string_like(s):
return s
if s == 'on':
return True
if s == 'off':
return False
raise ValueError("string argument must be either 'on' or 'off'")


def get_sample_data(fname, asfileobj=True):
"""
Return a sample data file. *fname* is a path relative to the
Expand Down Expand Up @@ -1724,8 +1736,8 @@ def simple_linear_interpolation(a, steps):

def recursive_remove(path):
if os.path.isdir(path):
for fname in glob.glob(os.path.join(path, '*')) + \
glob.glob(os.path.join(path, '.*')):
for fname in (glob.glob(os.path.join(path, '*')) +
glob.glob(os.path.join(path, '.*'))):
if os.path.isdir(fname):
recursive_remove(fname)
os.removedirs(fname)
Expand Down
3 changes: 2 additions & 1 deletion 3 lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import matplotlib.colorbar
from matplotlib import _pylab_helpers, interactive
from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
from matplotlib.cbook import _string_to_bool
from matplotlib import docstring
from matplotlib.backend_bases import FigureCanvasBase
from matplotlib.figure import Figure, figaspect
Expand All @@ -35,7 +36,7 @@
from matplotlib.rcsetup import interactive_bk as _interactive_bk
from matplotlib.artist import getp, get, Artist
from matplotlib.artist import setp as _setp
from matplotlib.axes import Axes, Subplot, _string_to_bool
from matplotlib.axes import Axes, Subplot
from matplotlib.projections import PolarAxes
from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
from matplotlib.scale import get_scale_docs, get_scale_names
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def grid(self, b=True, **kwargs):
# TODO: Operate on each axes separately
if len(kwargs) :
b = True
self._draw_grid = maxes._string_to_bool(b)
self._draw_grid = cbook._string_to_bool(b)

def ticklabel_format(self, **kwargs) :
"""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.