Skip to content

Commit 4bc74f5

Browse files
committed
add ASVs
1 parent 2fa526f commit 4bc74f5

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import numpy as np
2+
3+
import pandas.util.testing as tm
4+
from pandas._libs.index import (Int64Engine, Int32Engine,
5+
Int16Engine, Int8Engine,
6+
UInt64Engine, UInt32Engine,
7+
UInt16Engine, UInt8Engine,
8+
Float64Engine, Float32Engine,
9+
ObjectEngine,
10+
)
11+
12+
13+
class NumericEngineIndexing(object):
14+
15+
goal_time = 0.2
16+
params = [[Int64Engine, Int32Engine, Int16Engine, Int8Engine,
17+
UInt64Engine, UInt32Engine, UInt16Engine, UInt8Engine,
18+
Float64Engine, Float32Engine,
19+
],
20+
['monotonic_incr', 'monotonic_decr', 'non_monotonic']
21+
]
22+
param_names = ['engine', 'index_type']
23+
24+
def setup(self, engine, index_type):
25+
N = 10**5
26+
values = list([1] * N + [2] * N + [3] * N)
27+
array_ = {
28+
'monotonic_incr': np.array(values, dtype=engine._dtype),
29+
'monotonic_decr': np.array(list(reversed(values)),
30+
dtype=engine._dtype),
31+
'non_monotonic': np.array([1, 2, 3] * N, dtype=engine._dtype),
32+
}[index_type]
33+
34+
self.data = engine(lambda: array_, len(array_))
35+
self.int_scalar = 2
36+
37+
def time_get_loc(self, engine, index_type):
38+
self.data.get_loc(self.int_scalar)
39+
40+
41+
class ObjectEngineIndexing(object):
42+
43+
goal_time = 0.2
44+
params = [[ObjectEngine],
45+
['monotonic_incr', 'monotonic_decr', 'non_monotonic']
46+
]
47+
param_names = ['engine', 'index_type']
48+
49+
def setup(self, engine, index_type):
50+
N = 10**5
51+
values = list('a' * N + 'b' * N + 'c' * N)
52+
array_ = {
53+
'monotonic_incr': np.array(values, dtype=engine._dtype),
54+
'monotonic_decr': np.array(list(reversed(values)),
55+
dtype=engine._dtype),
56+
'non_monotonic': np.array(list('abc') * N, dtype=engine._dtype),
57+
}[index_type]
58+
59+
self.data = engine(lambda: array_, len(array_))
60+
self.int_scalar = 'b'
61+
62+
def time_get_loc(self, engine, index_type):
63+
self.data.get_loc(self.int_scalar)

pandas/tests/indexes/test_engine.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import pandas as pd
77
from pandas._libs.index import (Int64Engine, UInt64Engine,
88
Float64Engine, ObjectEngine)
9-
from pandas._libs.lib import is_scalar
10-
import pandas.util.testing as tm
119

1210

1311
class TestNumericEngine(object):
@@ -57,8 +55,8 @@ def test_is_unique(self, values, expected, num_engine):
5755
@pytest.mark.parametrize('values, value, expected', [
5856
([1, 2, 3], 2, 1),
5957
([1, 2, 2, 3], 2, slice(1, 3)),
60-
([3, 2, 2, 1], 2, np.array([False, True, True, False])),
61-
([1, 2, 2, 1], 2, np.array([False, True, True, False])),
58+
([3, 2, 2, 1], 2, np.array([False, True, True, False])),
59+
([1, 2, 2, 1], 2, np.array([False, True, True, False])),
6260
([1, 3, 2], 2, 2),
6361
])
6462
def test_get_loc(self, values, value, expected, num_engine):
@@ -125,8 +123,8 @@ def test_is_unique(self, values, expected):
125123
@pytest.mark.parametrize('values, value, expected', [
126124
(list('abc'), 'b', 1),
127125
(list('abbc'), 'b', slice(1, 3)),
128-
(list('cbba'), 'b', np.array([False, True, True, False])),
129-
(list('abba'), 'b', np.array([False, True, True, False])),
126+
(list('cbba'), 'b', np.array([False, True, True, False])),
127+
(list('abba'), 'b', np.array([False, True, True, False])),
130128
(list('acb'), 'b', 2),
131129
])
132130
def test_get_loc(self, values, value, expected):

0 commit comments

Comments
 (0)