|  | 
| 3 | 3 | from pandas import Series, Index, DatetimeIndex, Timestamp, MultiIndex | 
| 4 | 4 | 
 | 
| 5 | 5 | 
 | 
|  | 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 gen_of_str(arr): | 
|  | 15 | + return (x for x in arr.astype(str)) | 
|  | 16 | + | 
|  | 17 | + | 
|  | 18 | +def arr_dict(arr): | 
|  | 19 | + return dict(zip(range(len(arr)), arr)) | 
|  | 20 | + | 
|  | 21 | + | 
|  | 22 | +def list_of_tuples(arr): | 
|  | 23 | + return [(i, -i) for i in arr] | 
|  | 24 | + | 
|  | 25 | + | 
|  | 26 | +def gen_of_tuples(arr): | 
|  | 27 | + return ((i, -i) for i in arr) | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +def list_of_lists(arr): | 
|  | 31 | + return [[i, -i] for i in arr] | 
|  | 32 | + | 
|  | 33 | + | 
|  | 34 | +def list_of_tuples_with_none(arr): | 
|  | 35 | + return [(i, -i) for i in arr][:-1] + [None] | 
|  | 36 | + | 
|  | 37 | + | 
|  | 38 | +def list_of_lists_with_none(arr): | 
|  | 39 | + return [[i, -i] for i in arr][:-1] + [None] | 
|  | 40 | + | 
|  | 41 | + | 
| 6 | 42 | class SeriesConstructors(object): | 
| 7 | 43 | 
 | 
| 8 | 44 |  param_names = ["data_fmt", "with_index"] | 
| 9 |  | - params = [[lambda x: x, | 
|  | 45 | + params = [[no_change, | 
| 10 | 46 |  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])], | 
|  | 47 | + list_of_str, | 
|  | 48 | + gen_of_str, | 
|  | 49 | + arr_dict, | 
|  | 50 | + list_of_tuples, | 
|  | 51 | + gen_of_tuples, | 
|  | 52 | + list_of_lists, | 
|  | 53 | + list_of_tuples_with_none, | 
|  | 54 | + list_of_lists_with_none], | 
| 17 | 55 |  [False, True]] | 
| 18 | 56 | 
 | 
| 19 | 57 |  def setup(self, data_fmt, with_index): | 
|  | 
0 commit comments