10
10
# these two get used in multiple tests, so define them here
11
11
@unpack_labeled_data (replace_names = ["x" , "y" ])
12
12
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 ))
14
15
15
16
16
17
@unpack_labeled_data (replace_names = ["x" , "y" ],
@@ -23,7 +24,8 @@ def plot_func_varags(ax, *args, **kwargs):
23
24
if k in kwargs :
24
25
all_args [i ] = kwargs [k ]
25
26
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 ))
27
29
28
30
29
31
all_funcs = [plot_func , plot_func_varags ]
@@ -80,7 +82,7 @@ def f():
80
82
81
83
82
84
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."""
84
86
try :
85
87
from pandas .util .testing import assert_produces_warning
86
88
except ImportError :
@@ -117,9 +119,12 @@ def f():
117
119
def test_function_call_without_data ():
118
120
"""test without data -> no replacements"""
119
121
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: " )
123
128
assert_equal (func (None , "x" , "y" , label = "text" ),
124
129
"x: ['x'], y: ['y'], ls: x, w: xyz, label: text" )
125
130
assert_equal (func (None , x = "x" , y = "y" , label = "" ),
@@ -194,20 +199,24 @@ def test_function_call_replace_all():
194
199
195
200
@unpack_labeled_data ()
196
201
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 )
198
204
199
205
assert_equal (func_replace_all (None , "a" , "b" , w = "x" , data = data ),
200
206
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b" )
201
207
assert_equal (func_replace_all (None , x = "a" , y = "b" , w = "x" , data = data ),
202
208
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b" )
203
209
assert_equal (func_replace_all (None , "a" , "b" , w = "x" , label = "" , data = data ),
204
210
"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" )
211
220
212
221
@unpack_labeled_data ()
213
222
def func_varags_replace_all (ax , * args , ** kwargs ):
@@ -218,19 +227,28 @@ def func_varags_replace_all(ax, *args, **kwargs):
218
227
if k in kwargs :
219
228
all_args [i ] = kwargs [k ]
220
229
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 )
222
232
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
224
235
assert_equal (func_varags_replace_all (None , x = "a" , y = "b" , w = "x" , data = data ),
225
236
"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" )
234
252
235
253
try :
236
254
from pandas .util .testing import assert_produces_warning
@@ -246,7 +264,8 @@ def test_no_label_replacements():
246
264
247
265
@unpack_labeled_data (replace_names = ["x" , "y" ], label_namer = None )
248
266
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 )
250
269
251
270
data = {"a" : [1 , 2 ], "b" : [8 , 9 ], "w" : "NOT" }
252
271
assert_equal (func_no_label (None , "a" , "b" , data = data ),
@@ -284,18 +303,23 @@ def funcy(ax, *args, **kwargs):
284
303
if k in kwargs :
285
304
all_args [i ] = kwargs [k ]
286
305
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 )
288
308
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 )
290
311
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")
292
314
assert_equal (func (None , "a" , "b" , w = "x" , label = "" , data = data ),
293
315
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: " )
294
316
assert_equal (func (None , "a" , "b" , w = "x" , label = "text" , data = data ),
295
317
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text" )
296
318
297
319
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 )
299
323
300
324
assert_equal (func2 (None , "a" , "b" , w = "x" , data = data ),
301
325
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b" )
0 commit comments