Skip to content

Commit 2d3ede6

Browse files
ASV: fix params to be strings (for better repr) (pandas-dev#13805)
1 parent fcf2d86 commit 2d3ede6

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

asv_bench/benchmarks/inference.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,26 @@ def time_dtype_infer_uint32(self):
139139

140140

141141
class to_numeric(object):
142+
143+
param_names = ['dtype', 'downcast']
144+
params = [['string-float', 'string-int', 'string-nint', 'datetime64',
145+
'int-list', 'int32'],
146+
[None, 'integer', 'signed', 'unsigned', 'float']]
147+
142148
N = 500000
143149

144-
param_names = ['data', 'downcast']
145-
params = [
146-
[(['1'] * (N / 2)) + ([2] * (N / 2)),
147-
(['-1'] * (N / 2)) + ([2] * (N / 2)),
148-
np.repeat(np.array(['1970-01-01', '1970-01-02'],
149-
dtype='datetime64[D]'), N),
150-
(['1.1'] * (N / 2)) + ([2] * (N / 2)),
151-
([1] * (N / 2)) + ([2] * (N / 2)),
152-
np.repeat(np.int32(1), N)],
153-
[None, 'integer', 'signed', 'unsigned', 'float'],
154-
]
155-
156-
def time_to_numeric(self, data, downcast):
157-
pd.to_numeric(data, downcast=downcast)
150+
data_dict = {
151+
'string-int': (['1'] * (N / 2)) + ([2] * (N / 2)),
152+
'string-nint': (['-1'] * (N / 2)) + ([2] * (N / 2)),
153+
'datetime64': np.repeat(np.array(['1970-01-01', '1970-01-02'],
154+
dtype='datetime64[D]'), N),
155+
'string-float': (['1.1'] * (N / 2)) + ([2] * (N / 2)),
156+
'int-list': ([1] * (N / 2)) + ([2] * (N / 2)),
157+
'int32': np.repeat(np.int32(1), N)
158+
}
159+
160+
def setup(self, dtype, downcast):
161+
self.data = self.data_dict[dtype]
162+
163+
def time_downcast(self, dtype, downcast):
164+
pd.to_numeric(self.data, downcast=downcast)

0 commit comments

Comments
 (0)