@@ -85,6 +85,26 @@ cdef ndarray _get_bool_indexer(ndarray values, object val):
85
85
_SIZE_CUTOFF = 1 _000_000
86
86
87
87
88
+ cdef _unpack_bool_indexer(ndarray[uint8_t, ndim= 1 , cast= True ] indexer, object val):
89
+ """
90
+ Possibly unpack a boolean mask to a single indexer.
91
+ """
92
+ # Returns ndarray[bool] or int
93
+ cdef:
94
+ ndarray[intp_t, ndim= 1 ] found
95
+ int count
96
+
97
+ found = np.where(indexer)[0 ]
98
+ count = len (found)
99
+
100
+ if count > 1 :
101
+ return indexer
102
+ if count == 1 :
103
+ return int (found[0 ])
104
+
105
+ raise KeyError (val)
106
+
107
+
88
108
@ cython.freelist (32 )
89
109
cdef class IndexEngine:
90
110
@@ -182,25 +202,7 @@ cdef class IndexEngine:
182
202
ndarray[uint8_t, ndim= 1 , cast= True ] indexer
183
203
184
204
indexer = _get_bool_indexer(self .values, val)
185
- return self ._unpack_bool_indexer(indexer, val)
186
-
187
- cdef _unpack_bool_indexer(self ,
188
- ndarray[uint8_t, ndim= 1 , cast= True ] indexer,
189
- object val):
190
- # Returns ndarray[bool] or int
191
- cdef:
192
- ndarray[intp_t, ndim= 1 ] found
193
- int count
194
-
195
- found = np.where(indexer)[0 ]
196
- count = len (found)
197
-
198
- if count > 1 :
199
- return indexer
200
- if count == 1 :
201
- return int (found[0 ])
202
-
203
- raise KeyError (val)
205
+ return _unpack_bool_indexer(indexer, val)
204
206
205
207
def sizeof (self , deep: bool = False ) -> int:
206
208
""" return the sizeof our mapping """
0 commit comments