Skip to content

Commit c8124ff

Browse files
committed
Add params for Duplicated and Factorize
1 parent a69ef64 commit c8124ff

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

asv_bench/benchmarks/algorithms.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,48 @@ class Factorize(object):
1717

1818
goal_time = 0.2
1919

20-
def setup(self):
20+
params = [True, False]
21+
param_names = ['sort']
22+
23+
def setup(self, sort):
2124
N = 10**5
2225
np.random.seed(1234)
2326
self.int_idx = pd.Int64Index(np.arange(N).repeat(5))
2427
self.float_idx = pd.Float64Index(np.random.randn(N).repeat(5))
2528
self.string_idx = tm.makeStringIndex(N)
2629

27-
def time_factorize_int(self):
28-
self.int_idx.factorize()
30+
def time_factorize_int(self, sort):
31+
self.int_idx.factorize(sort=sort)
2932

30-
def time_factorize_float(self):
31-
self.float_idx.factorize()
33+
def time_factorize_float(self, sort):
34+
self.float_idx.factorize(sort=sort)
3235

33-
def time_factorize_string(self):
34-
self.string_idx.factorize()
36+
def time_factorize_string(self, sort):
37+
self.string_idx.factorize(sort=sort)
3538

3639

3740
class Duplicated(object):
3841

3942
goal_time = 0.2
4043

41-
def setup(self):
44+
params = ['first', 'last', False]
45+
param_names = ['keep']
46+
47+
def setup(self, keep):
4248
N = 10**5
4349
np.random.seed(1234)
4450
self.int_idx = pd.Int64Index(np.arange(N).repeat(5))
4551
self.float_idx = pd.Float64Index(np.random.randn(N).repeat(5))
52+
self.string_idx = tm.makeStringIndex(N)
53+
54+
def time_duplicated_int(self, keep):
55+
self.int_idx.duplicated(keep=keep)
4656

47-
def time_duplicated_int(self):
48-
self.int_idx.duplicated()
57+
def time_duplicated_float(self, keep):
58+
self.float_idx.duplicated(keep=keep)
4959

50-
def time_duplicated_float(self):
51-
self.float_idx.duplicated()
60+
def time_duplicated_string(self, keep):
61+
self.string_idx.duplicated(keep=keep)
5262

5363

5464
class DuplicatedUniqueIndex(object):

0 commit comments

Comments
 (0)