Skip to content

Commit d8bfcef

Browse files
committed
CLN: only construct case necessary for benchmark
1 parent 9c8d273 commit d8bfcef

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

asv_bench/benchmarks/categoricals.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ def setup(self, index):
225225
N = 10**6
226226
categories = ['a', 'b', 'c']
227227
values = [0] * N + [1] * N + [2] * N
228-
indices = {
229-
'monotonic_incr': pd.Categorical.from_codes(values,
230-
categories=categories),
231-
'monotonic_decr': pd.Categorical.from_codes(list(reversed(values)),
232-
categories=categories),
233-
'non_monotonic': pd.Categorical.from_codes([0, 1, 2] * N,
234-
categories=categories)
235-
}
236-
self.data = indices[index]
228+
if index == 'monotonic_incr':
229+
self.data = pd.Categorical.from_codes(values, categories=categories)
230+
elif index == 'monotonic_decr':
231+
self.data = pd.Categorical.from_codes(list(reversed(values)),
232+
categories=categories)
233+
elif index == 'non_monotonic':
234+
self.data = pd.Categorical.from_codes([0, 1, 2] * N,
235+
categories=categories)
236+
else:
237+
raise ValueError('Invalid index param: {}'.format(index))
237238

238239
self.scalar = 10000
239240
self.list = list(range(10000))

0 commit comments

Comments
 (0)