Skip to content

Commit ff15bae

Browse files
committed
CLN: replace lambdas with named functions so they are labeled in asv
1 parent 9175387 commit ff15bae

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

asv_bench/benchmarks/ctors.py

+35-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,45 @@
33
from pandas import Series, Index, DatetimeIndex, Timestamp, MultiIndex
44

55

6+
def no_change(arr):
7+
return arr
8+
9+
10+
def list_of_str(arr):
11+
return list(arr.astype(str))
12+
13+
14+
def arr_dict(arr):
15+
return dict(zip(range(len(arr)), arr))
16+
17+
18+
def list_of_tuples(arr):
19+
return [(i, -i) for i in arr]
20+
21+
22+
def list_of_lists(arr):
23+
return [[i, -i] for i in arr]
24+
25+
26+
def list_of_tuples_with_none(arr):
27+
return ([(i, -i) for i in arr][:-1] + [None])
28+
29+
30+
def list_of_lists_with_none(arr):
31+
return ([[i, -i] for i in arr][:-1] + [None])
32+
33+
634
class SeriesConstructors(object):
735

836
param_names = ["data_fmt", "with_index"]
9-
params = [[lambda x: x,
37+
params = [[no_change,
1038
list,
11-
lambda arr: list(arr.astype(str)),
12-
lambda arr: dict(zip(range(len(arr)), arr)),
13-
lambda arr: [(i, -i) for i in arr],
14-
lambda arr: [[i, -i] for i in arr],
15-
lambda arr: ([(i, -i) for i in arr][:-1] + [None]),
16-
lambda arr: ([[i, -i] for i in arr][:-1] + [None])],
39+
list_of_str,
40+
arr_dict,
41+
list_of_tuples,
42+
list_of_lists,
43+
list_of_tuples_with_none,
44+
list_of_lists_with_none],
1745
[False, True]]
1846

1947
def setup(self, data_fmt, with_index):

0 commit comments

Comments
 (0)