Skip to content

Commit d618546

Browse files
committed
fixing pyplot.py generating boilerplate code to avoid unicode strings
1 parent 06fd264 commit d618546

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

boilerplate.py

+7
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ def format_value(value):
217217
args.pop(0) # remove 'self' argument
218218
if defaults is None:
219219
defaults = ()
220+
else:
221+
def_edited = []
222+
for val in defaults:
223+
if isinstance(val, unicode):
224+
val = val.encode('ascii', 'ignore')
225+
def_edited.append(val)
226+
defaults = tuple(def_edited)
220227

221228
# How to call the wrapped function
222229
call = []

lib/matplotlib/pyplot.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,7 @@ def broken_barh(xranges, yrange, hold=None, **kwargs):
25992599
# This function was autogenerated by boilerplate.py. Do not edit as
26002600
# changes will be lost
26012601
@_autogen_docstring(Axes.boxplot)
2602-
def boxplot(x, notch=False, sym=u'b+', vert=True, whis=1.5, positions=None,
2602+
def boxplot(x, notch=False, sym='b+', vert=True, whis=1.5, positions=None,
26032603
widths=None, patch_artist=False, bootstrap=None, usermedians=None,
26042604
conf_intervals=None, meanline=False, showmeans=False, showcaps=True,
26052605
showbox=True, showfliers=True, boxprops=None, labels=None,
@@ -2631,8 +2631,8 @@ def boxplot(x, notch=False, sym=u'b+', vert=True, whis=1.5, positions=None,
26312631
# changes will be lost
26322632
@_autogen_docstring(Axes.cohere)
26332633
def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
2634-
window=mlab.window_hanning, noverlap=0, pad_to=None,
2635-
sides=u'default', scale_by_freq=None, hold=None, **kwargs):
2634+
window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default',
2635+
scale_by_freq=None, hold=None, **kwargs):
26362636
ax = gca()
26372637
# allow callers to override the hold state by passing hold=True|False
26382638
washold = ax.ishold()
@@ -2729,7 +2729,7 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
27292729
# This function was autogenerated by boilerplate.py. Do not edit as
27302730
# changes will be lost
27312731
@_autogen_docstring(Axes.errorbar)
2732-
def errorbar(x, y, yerr=None, xerr=None, fmt=u'-', ecolor=None, elinewidth=None,
2732+
def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
27332733
capsize=3, barsabove=False, lolims=False, uplims=False,
27342734
xlolims=False, xuplims=False, errorevery=1, capthick=None,
27352735
hold=None, **kwargs):
@@ -2754,9 +2754,9 @@ def errorbar(x, y, yerr=None, xerr=None, fmt=u'-', ecolor=None, elinewidth=None,
27542754
# This function was autogenerated by boilerplate.py. Do not edit as
27552755
# changes will be lost
27562756
@_autogen_docstring(Axes.eventplot)
2757-
def eventplot(positions, orientation=u'horizontal', lineoffsets=1,
2758-
linelengths=1, linewidths=None, colors=None, linestyles=u'solid',
2759-
hold=None, **kwargs):
2757+
def eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1,
2758+
linewidths=None, colors=None, linestyles='solid', hold=None,
2759+
**kwargs):
27602760
ax = gca()
27612761
# allow callers to override the hold state by passing hold=True|False
27622762
washold = ax.ishold()
@@ -2832,9 +2832,9 @@ def fill_betweenx(y, x1, x2=0, where=None, hold=None, **kwargs):
28322832
# This function was autogenerated by boilerplate.py. Do not edit as
28332833
# changes will be lost
28342834
@_autogen_docstring(Axes.hexbin)
2835-
def hexbin(x, y, C=None, gridsize=100, bins=None, xscale=u'linear',
2836-
yscale=u'linear', extent=None, cmap=None, norm=None, vmin=None,
2837-
vmax=None, alpha=None, linewidths=None, edgecolors=u'none',
2835+
def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear',
2836+
yscale='linear', extent=None, cmap=None, norm=None, vmin=None,
2837+
vmax=None, alpha=None, linewidths=None, edgecolors='none',
28382838
reduce_C_function=np.mean, mincnt=None, marginals=False, hold=None,
28392839
**kwargs):
28402840
ax = gca()
@@ -2860,7 +2860,7 @@ def hexbin(x, y, C=None, gridsize=100, bins=None, xscale=u'linear',
28602860
# changes will be lost
28612861
@_autogen_docstring(Axes.hist)
28622862
def hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False,
2863-
bottom=None, histtype=u'bar', align=u'mid', orientation=u'vertical',
2863+
bottom=None, histtype='bar', align='mid', orientation='vertical',
28642864
rwidth=None, log=False, color=None, label=None, stacked=False,
28652865
hold=None, **kwargs):
28662866
ax = gca()
@@ -2904,8 +2904,8 @@ def hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None,
29042904
# This function was autogenerated by boilerplate.py. Do not edit as
29052905
# changes will be lost
29062906
@_autogen_docstring(Axes.hlines)
2907-
def hlines(y, xmin, xmax, colors=u'k', linestyles=u'solid', label=u'',
2908-
hold=None, **kwargs):
2907+
def hlines(y, xmin, xmax, colors='k', linestyles='solid', label='', hold=None,
2908+
**kwargs):
29092909
ax = gca()
29102910
# allow callers to override the hold state by passing hold=True|False
29112911
washold = ax.ishold()
@@ -3087,7 +3087,7 @@ def plot(*args, **kwargs):
30873087
# This function was autogenerated by boilerplate.py. Do not edit as
30883088
# changes will be lost
30893089
@_autogen_docstring(Axes.plot_date)
3090-
def plot_date(x, y, fmt=u'o', tz=None, xdate=True, ydate=False, hold=None,
3090+
def plot_date(x, y, fmt='o', tz=None, xdate=True, ydate=False, hold=None,
30913091
**kwargs):
30923092
ax = gca()
30933093
# allow callers to override the hold state by passing hold=True|False
@@ -3166,7 +3166,7 @@ def quiverkey(*args, **kw):
31663166
# This function was autogenerated by boilerplate.py. Do not edit as
31673167
# changes will be lost
31683168
@_autogen_docstring(Axes.scatter)
3169-
def scatter(x, y, s=20, c=u'b', marker=u'o', cmap=None, norm=None, vmin=None,
3169+
def scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None,
31703170
vmax=None, alpha=None, linewidths=None, verts=None, hold=None,
31713171
**kwargs):
31723172
ax = gca()
@@ -3304,7 +3304,7 @@ def step(x, y, *args, **kwargs):
33043304
# changes will be lost
33053305
@_autogen_docstring(Axes.streamplot)
33063306
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
3307-
norm=None, arrowsize=1, arrowstyle=u'-|>', minlength=0.1,
3307+
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
33083308
transform=None, zorder=1, hold=None):
33093309
ax = gca()
33103310
# allow callers to override the hold state by passing hold=True|False
@@ -3399,8 +3399,8 @@ def triplot(*args, **kwargs):
33993399
# This function was autogenerated by boilerplate.py. Do not edit as
34003400
# changes will be lost
34013401
@_autogen_docstring(Axes.vlines)
3402-
def vlines(x, ymin, ymax, colors=u'k', linestyles=u'solid', label=u'',
3403-
hold=None, **kwargs):
3402+
def vlines(x, ymin, ymax, colors='k', linestyles='solid', label='', hold=None,
3403+
**kwargs):
34043404
ax = gca()
34053405
# allow callers to override the hold state by passing hold=True|False
34063406
washold = ax.ishold()
@@ -3465,7 +3465,7 @@ def cla():
34653465
# This function was autogenerated by boilerplate.py. Do not edit as
34663466
# changes will be lost
34673467
@docstring.copy_dedent(Axes.grid)
3468-
def grid(b=None, which=u'major', axis=u'both', **kwargs):
3468+
def grid(b=None, which='major', axis='both', **kwargs):
34693469
ret = gca().grid(b=b, which=which, axis=axis, **kwargs)
34703470
draw_if_interactive()
34713471
return ret
@@ -3513,15 +3513,15 @@ def ticklabel_format(**kwargs):
35133513
# This function was autogenerated by boilerplate.py. Do not edit as
35143514
# changes will be lost
35153515
@docstring.copy_dedent(Axes.locator_params)
3516-
def locator_params(axis=u'both', tight=None, **kwargs):
3516+
def locator_params(axis='both', tight=None, **kwargs):
35173517
ret = gca().locator_params(axis=axis, tight=tight, **kwargs)
35183518
draw_if_interactive()
35193519
return ret
35203520

35213521
# This function was autogenerated by boilerplate.py. Do not edit as
35223522
# changes will be lost
35233523
@docstring.copy_dedent(Axes.tick_params)
3524-
def tick_params(axis=u'both', **kwargs):
3524+
def tick_params(axis='both', **kwargs):
35253525
ret = gca().tick_params(axis=axis, **kwargs)
35263526
draw_if_interactive()
35273527
return ret
@@ -3537,7 +3537,7 @@ def margins(*args, **kw):
35373537
# This function was autogenerated by boilerplate.py. Do not edit as
35383538
# changes will be lost
35393539
@docstring.copy_dedent(Axes.autoscale)
3540-
def autoscale(enable=True, axis=u'both', tight=None):
3540+
def autoscale(enable=True, axis='both', tight=None):
35413541
ret = gca().autoscale(enable=enable, axis=axis, tight=tight)
35423542
draw_if_interactive()
35433543
return ret

0 commit comments

Comments
 (0)