Skip to content

Commit 704ee8f

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

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

asv_bench/benchmarks/categoricals.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,17 @@ 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,
230+
categories=categories)
231+
elif index == 'monotonic_decr':
232+
self.data = pd.Categorical.from_codes(list(reversed(values)),
233+
categories=categories)
234+
elif index == 'non_monotonic':
235+
self.data = pd.Categorical.from_codes([0, 1, 2] * N,
236+
categories=categories)
237+
else:
238+
raise ValueError('Invalid index param: {}'.format(index))
237239

238240
self.scalar = 10000
239241
self.list = list(range(10000))

0 commit comments

Comments
 (0)