forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexing_engines.py
60 lines (47 loc) · 2.06 KB
/
indexing_engines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import numpy as np
from pandas._libs.index import (Int64Engine, Int32Engine,
Int16Engine, Int8Engine,
UInt64Engine, UInt32Engine,
UInt16Engine, UInt8Engine,
Float64Engine, Float32Engine,
ObjectEngine,
)
class NumericEngineIndexing(object):
goal_time = 0.2
params = [[Int64Engine, Int32Engine, Int16Engine, Int8Engine,
UInt64Engine, UInt32Engine, UInt16Engine, UInt8Engine,
Float64Engine, Float32Engine,
],
['monotonic_incr', 'monotonic_decr', 'non_monotonic']
]
param_names = ['engine', 'index_type']
def setup(self, engine, index_type):
N = 10**5
values = list([1] * N + [2] * N + [3] * N)
array_ = {
'monotonic_incr': np.array(values, dtype=engine._dtype),
'monotonic_decr': np.array(list(reversed(values)),
dtype=engine._dtype),
'non_monotonic': np.array([1, 2, 3] * N, dtype=engine._dtype),
}[index_type]
self.data = engine(lambda: array_, len(array_))
def time_get_loc(self, engine, index_type):
self.data.get_loc(2)
class ObjectEngineIndexing(object):
goal_time = 0.2
params = [[ObjectEngine],
['monotonic_incr', 'monotonic_decr', 'non_monotonic']
]
param_names = ['engine', 'index_type']
def setup(self, engine, index_type):
N = 10**5
values = list('a' * N + 'b' * N + 'c' * N)
array_ = {
'monotonic_incr': np.array(values, dtype=engine._dtype),
'monotonic_decr': np.array(list(reversed(values)),
dtype=engine._dtype),
'non_monotonic': np.array(list('abc') * N, dtype=engine._dtype),
}[index_type]
self.data = engine(lambda: array_, len(array_))
def time_get_loc(self, engine, index_type):
self.data.get_loc(2)