From 06a5fa4123e15340a9b9917d1fb339b5e8503e45 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 26 Jul 2016 16:48:50 +0200 Subject: [PATCH] ASV: fix params to be strings (for better repr) --- asv_bench/benchmarks/inference.py | 35 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/asv_bench/benchmarks/inference.py b/asv_bench/benchmarks/inference.py index ee9d3104be4b1..0f9689dadcbb0 100644 --- a/asv_bench/benchmarks/inference.py +++ b/asv_bench/benchmarks/inference.py @@ -139,19 +139,26 @@ def time_dtype_infer_uint32(self): class to_numeric(object): + + param_names = ['dtype', 'downcast'] + params = [['string-float', 'string-int', 'string-nint', 'datetime64', + 'int-list', 'int32'], + [None, 'integer', 'signed', 'unsigned', 'float']] + N = 500000 - param_names = ['data', 'downcast'] - params = [ - [(['1'] * (N / 2)) + ([2] * (N / 2)), - (['-1'] * (N / 2)) + ([2] * (N / 2)), - np.repeat(np.array(['1970-01-01', '1970-01-02'], - dtype='datetime64[D]'), N), - (['1.1'] * (N / 2)) + ([2] * (N / 2)), - ([1] * (N / 2)) + ([2] * (N / 2)), - np.repeat(np.int32(1), N)], - [None, 'integer', 'signed', 'unsigned', 'float'], - ] - - def time_to_numeric(self, data, downcast): - pd.to_numeric(data, downcast=downcast) + data_dict = { + 'string-int': (['1'] * (N / 2)) + ([2] * (N / 2)), + 'string-nint': (['-1'] * (N / 2)) + ([2] * (N / 2)), + 'datetime64': np.repeat(np.array(['1970-01-01', '1970-01-02'], + dtype='datetime64[D]'), N), + 'string-float': (['1.1'] * (N / 2)) + ([2] * (N / 2)), + 'int-list': ([1] * (N / 2)) + ([2] * (N / 2)), + 'int32': np.repeat(np.int32(1), N) + } + + def setup(self, dtype, downcast): + self.data = self.data_dict[dtype] + + def time_downcast(self, dtype, downcast): + pd.to_numeric(self.data, downcast=downcast)