Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASV: fix params to be strings (for better repr) #13805

Merged
merged 1 commit into from
Jul 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions asv_bench/benchmarks/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)