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

Skip to content

Commit 346a014

Browse files
committed
PEP8: more line length fixes
1 parent 3273673 commit 346a014

File tree

2 files changed

+71
-38
lines changed

2 files changed

+71
-38
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,8 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
981981

982982
return coll
983983

984-
@unpack_labeled_data(replace_names=["x", "ymin", "ymax", "colors"], label_namer="x")
984+
@unpack_labeled_data(replace_names=["x", "ymin", "ymax", "colors"],
985+
label_namer="x")
985986
@docstring.dedent_interpd
986987
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
987988
label='', **kwargs):
@@ -1822,8 +1823,10 @@ def step(self, x, y, *args, **kwargs):
18221823

18231824
return self.plot(x, y, *args, **kwargs)
18241825

1825-
@unpack_labeled_data(replace_names=["left", "height", "width", "bottom", "color", "edgecolor",
1826-
"linewidth", "tick_label", "xerr", "yerr", "ecolor"],
1826+
@unpack_labeled_data(replace_names=["left", "height", "width", "bottom",
1827+
"color", "edgecolor", "linewidth",
1828+
"tick_label", "xerr", "yerr",
1829+
"ecolor"],
18271830
label_namer=None)
18281831
@docstring.dedent_interpd
18291832
def bar(self, left, height, width=0.8, bottom=None, **kwargs):
@@ -2392,7 +2395,8 @@ def stem(self, *args, **kwargs):
23922395

23932396
return stem_container
23942397

2395-
@unpack_labeled_data(replace_names=['x', 'labels', 'colors'], label_namer=None)
2398+
@unpack_labeled_data(replace_names=['x', 'labels', 'colors'],
2399+
label_namer=None)
23962400
def pie(self, x, explode=None, labels=None, colors=None,
23972401
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
23982402
startangle=None, radius=None, counterclock=True,
@@ -2612,7 +2616,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
26122616
else:
26132617
return slices, texts, autotexts
26142618

2615-
@unpack_labeled_data(replace_names=["x", "y", "xerr", "yerr"], label_namer="y")
2619+
@unpack_labeled_data(replace_names=["x", "y", "xerr", "yerr"],
2620+
label_namer="y")
26162621
@docstring.dedent_interpd
26172622
def errorbar(self, x, y, yerr=None, xerr=None,
26182623
fmt='', ecolor=None, elinewidth=None, capsize=None,
@@ -3660,8 +3665,9 @@ def dopatch(xs, ys, **kwargs):
36603665
return dict(whiskers=whiskers, caps=caps, boxes=boxes,
36613666
medians=medians, fliers=fliers, means=means)
36623667

3663-
@unpack_labeled_data(replace_names=["x", "y", "s", "c", "linewidths", "edgecolors",
3664-
'facecolor', 'facecolors', 'color'], # alias for c
3668+
@unpack_labeled_data(replace_names=["x", "y", "s", "linewidths",
3669+
"edgecolors", "c", 'facecolor',
3670+
'facecolors', 'color'],
36653671
label_namer="y")
36663672
@docstring.dedent_interpd
36673673
def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
@@ -4387,7 +4393,8 @@ def stackplot(self, x, *args, **kwargs):
43874393
return mstack.stackplot(self, x, *args, **kwargs)
43884394
stackplot.__doc__ = mstack.stackplot.__doc__
43894395

4390-
@unpack_labeled_data(replace_names=["x", "y", "u", "v", "start_points"], label_namer=None)
4396+
@unpack_labeled_data(replace_names=["x", "y", "u", "v", "start_points"],
4397+
label_namer=None)
43914398
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
43924399
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
43934400
minlength=0.1, transform=None, zorder=1, start_points=None):
@@ -4478,7 +4485,8 @@ def fill(self, *args, **kwargs):
44784485
self.autoscale_view()
44794486
return patches
44804487

4481-
@unpack_labeled_data(replace_names=["x", "y1", "y2", "where"], label_namer=None)
4488+
@unpack_labeled_data(replace_names=["x", "y1", "y2", "where"],
4489+
label_namer=None)
44824490
@docstring.dedent_interpd
44834491
def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
44844492
step=None,
@@ -4632,7 +4640,8 @@ def get_interp_point(ind):
46324640
self.autoscale_view()
46334641
return collection
46344642

4635-
@unpack_labeled_data(replace_names=["y", "x1", "x2", "where"], label_namer=None)
4643+
@unpack_labeled_data(replace_names=["y", "x1", "x2", "where"],
4644+
label_namer=None)
46364645
@docstring.dedent_interpd
46374646
def fill_betweenx(self, y, x1, x2=0, where=None,
46384647
step=None, **kwargs):

lib/matplotlib/tests/test_labled_data_unpacking.py

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# these two get used in multiple tests, so define them here
1111
@unpack_labeled_data(replace_names=["x", "y"])
1212
def plot_func(ax, x, y, ls="x", label=None, w="xyz"):
13-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
13+
return ("x: %s, y: %s, ls: %s, w: %s, label: %s" % (
14+
list(x), list(y), ls, w, label))
1415

1516

1617
@unpack_labeled_data(replace_names=["x", "y"],
@@ -23,7 +24,8 @@ def plot_func_varags(ax, *args, **kwargs):
2324
if k in kwargs:
2425
all_args[i] = kwargs[k]
2526
x, y, ls, label, w = all_args
26-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
27+
return ("x: %s, y: %s, ls: %s, w: %s, label: %s" % (
28+
list(x), list(y), ls, w, label))
2729

2830

2931
all_funcs = [plot_func, plot_func_varags]
@@ -80,7 +82,7 @@ def f():
8082

8183

8284
def test_label_problems_at_runtime():
83-
"""These are tests for behaviour which would actually be nice to get rid of."""
85+
"""Tests for behaviour which would actually be nice to get rid of."""
8486
try:
8587
from pandas.util.testing import assert_produces_warning
8688
except ImportError:
@@ -117,9 +119,12 @@ def f():
117119
def test_function_call_without_data():
118120
"""test without data -> no replacements"""
119121
for func in all_funcs:
120-
assert_equal(func(None, "x", "y"), "x: ['x'], y: ['y'], ls: x, w: xyz, label: None")
121-
assert_equal(func(None, x="x", y="y"), "x: ['x'], y: ['y'], ls: x, w: xyz, label: None")
122-
assert_equal(func(None, "x", "y", label=""), "x: ['x'], y: ['y'], ls: x, w: xyz, label: ")
122+
assert_equal(func(None, "x", "y"),
123+
"x: ['x'], y: ['y'], ls: x, w: xyz, label: None")
124+
assert_equal(func(None, x="x", y="y"),
125+
"x: ['x'], y: ['y'], ls: x, w: xyz, label: None")
126+
assert_equal(func(None, "x", "y", label=""),
127+
"x: ['x'], y: ['y'], ls: x, w: xyz, label: ")
123128
assert_equal(func(None, "x", "y", label="text"),
124129
"x: ['x'], y: ['y'], ls: x, w: xyz, label: text")
125130
assert_equal(func(None, x="x", y="y", label=""),
@@ -194,20 +199,24 @@ def test_function_call_replace_all():
194199

195200
@unpack_labeled_data()
196201
def func_replace_all(ax, x, y, ls="x", label=None, w="NOT"):
197-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
202+
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (
203+
list(x), list(y), ls, w, label)
198204

199205
assert_equal(func_replace_all(None, "a", "b", w="x", data=data),
200206
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b")
201207
assert_equal(func_replace_all(None, x="a", y="b", w="x", data=data),
202208
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b")
203209
assert_equal(func_replace_all(None, "a", "b", w="x", label="", data=data),
204210
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
205-
assert_equal(func_replace_all(None, "a", "b", w="x", label="text", data=data),
206-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
207-
assert_equal(func_replace_all(None, x="a", y="b", w="x", label="", data=data),
208-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
209-
assert_equal(func_replace_all(None, x="a", y="b", w="x", label="text", data=data),
210-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
211+
assert_equal(
212+
func_replace_all(None, "a", "b", w="x", label="text", data=data),
213+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
214+
assert_equal(
215+
func_replace_all(None, x="a", y="b", w="x", label="", data=data),
216+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
217+
assert_equal(
218+
func_replace_all(None, x="a", y="b", w="x", label="text", data=data),
219+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
211220

212221
@unpack_labeled_data()
213222
def func_varags_replace_all(ax, *args, **kwargs):
@@ -218,19 +227,28 @@ def func_varags_replace_all(ax, *args, **kwargs):
218227
if k in kwargs:
219228
all_args[i] = kwargs[k]
220229
x, y, ls, label, w = all_args
221-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
230+
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (
231+
list(x), list(y), ls, w, label)
222232

223-
# in the first case, we can't get a "y" argument, as we don't know the names of the *args
233+
# in the first case, we can't get a "y" argument,
234+
# as we don't know the names of the *args
224235
assert_equal(func_varags_replace_all(None, x="a", y="b", w="x", data=data),
225236
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b")
226-
assert_equal(func_varags_replace_all(None, "a", "b", w="x", label="", data=data),
227-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
228-
assert_equal(func_varags_replace_all(None, "a", "b", w="x", label="text", data=data),
229-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
230-
assert_equal(func_varags_replace_all(None, x="a", y="b", w="x", label="", data=data),
231-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
232-
assert_equal(func_varags_replace_all(None, x="a", y="b", w="x", label="text", data=data),
233-
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
237+
assert_equal(
238+
func_varags_replace_all(None, "a", "b", w="x", label="", data=data),
239+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
240+
assert_equal(
241+
func_varags_replace_all(None, "a", "b", w="x", label="text",
242+
data=data),
243+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
244+
assert_equal(
245+
func_varags_replace_all(None, x="a", y="b", w="x", label="",
246+
data=data),
247+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
248+
assert_equal(
249+
func_varags_replace_all(None, x="a", y="b", w="x", label="text",
250+
data=data),
251+
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
234252

235253
try:
236254
from pandas.util.testing import assert_produces_warning
@@ -246,7 +264,8 @@ def test_no_label_replacements():
246264

247265
@unpack_labeled_data(replace_names=["x", "y"], label_namer=None)
248266
def func_no_label(ax, x, y, ls="x", label=None, w="xyz"):
249-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
267+
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (
268+
list(x), list(y), ls, w, label)
250269

251270
data = {"a": [1, 2], "b": [8, 9], "w": "NOT"}
252271
assert_equal(func_no_label(None, "a", "b", data=data),
@@ -284,18 +303,23 @@ def funcy(ax, *args, **kwargs):
284303
if k in kwargs:
285304
all_args[i] = kwargs[k]
286305
x, y, ls, label, w = all_args
287-
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (list(x), list(y), ls, w, label)
306+
return "x: %s, y: %s, ls: %s, w: %s, label: %s" % (
307+
list(x), list(y), ls, w, label)
288308

289-
func = unpack_labeled_data(replace_all_args=True, replace_names=["w"])(funcy)
309+
func = unpack_labeled_data(replace_all_args=True, replace_names=["w"])(
310+
funcy)
290311

291-
# assert_equal(func(None, "a","b", w="x", data=data), "x: [1, 2], y: [8, 9], ls: x, w: xyz, label: None")
312+
# assert_equal(func(None, "a","b", w="x", data=data),
313+
# "x: [1, 2], y: [8, 9], ls: x, w: xyz, label: None")
292314
assert_equal(func(None, "a", "b", w="x", label="", data=data),
293315
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
294316
assert_equal(func(None, "a", "b", w="x", label="text", data=data),
295317
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
296318

297319
func2 = unpack_labeled_data(replace_all_args=True, replace_names=["w"],
298-
positional_parameter_names=["x", "y", "ls", "label", "w"])(funcy)
320+
positional_parameter_names=["x", "y", "ls",
321+
"label", "w"])(
322+
funcy)
299323

300324
assert_equal(func2(None, "a", "b", w="x", data=data),
301325
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b")

0 commit comments

Comments
 (0)