@@ -43,10 +43,11 @@ cdef class Reducer:
43
43
"""
44
44
cdef:
45
45
Py_ssize_t increment, chunksize, nresults
46
- object arr, dummy, f, labels, typ, ityp, index
46
+ object dummy, f, labels, typ, ityp, index
47
+ ndarray arr
47
48
48
- def __init__ (self , object arr , object f , axis = 1 , dummy = None , labels = None ):
49
- n, k = arr.shape
49
+ def __init__ (self , ndarray arr , object f , axis = 1 , dummy = None , labels = None ):
50
+ n, k = ( < object > arr) .shape
50
51
51
52
if axis == 0 :
52
53
if not arr.flags.f_contiguous:
@@ -102,7 +103,7 @@ cdef class Reducer:
102
103
ndarray arr, result, chunk
103
104
Py_ssize_t i, incr
104
105
flatiter it
105
- bint has_labels, has_ndarray_labels
106
+ bint has_labels
106
107
object res, name, labels, index
107
108
object cached_typ = None
108
109
@@ -112,17 +113,13 @@ cdef class Reducer:
112
113
chunk.data = arr.data
113
114
labels = self .labels
114
115
has_labels = labels is not None
115
- has_ndarray_labels = util.is_array(labels)
116
116
has_index = self .index is not None
117
117
incr = self .increment
118
118
119
119
try :
120
120
for i in range (self .nresults):
121
121
122
- if has_ndarray_labels:
123
- name = labels[i]
124
- elif has_labels:
125
- # labels is an ExtensionArray
122
+ if has_labels:
126
123
name = labels[i]
127
124
else :
128
125
name = None
@@ -206,11 +203,10 @@ cdef class SeriesBinGrouper(_BaseGrouper):
206
203
Py_ssize_t nresults, ngroups
207
204
208
205
cdef public:
209
- object arr, index, dummy_arr, dummy_index
206
+ ndarray arr, index, dummy_arr, dummy_index
210
207
object values, f, bins, typ, ityp, name
211
208
212
209
def __init__ (self , object series , object f , object bins , object dummy ):
213
- n = len (series)
214
210
215
211
assert dummy is not None # always obj[:0]
216
212
@@ -317,12 +313,11 @@ cdef class SeriesGrouper(_BaseGrouper):
317
313
Py_ssize_t nresults, ngroups
318
314
319
315
cdef public:
320
- object arr, index, dummy_arr, dummy_index
316
+ ndarray arr, index, dummy_arr, dummy_index
321
317
object f, labels, values, typ, ityp, name
322
318
323
319
def __init__ (self , object series , object f , object labels ,
324
320
Py_ssize_t ngroups , object dummy ):
325
- n = len (series)
326
321
327
322
# in practice we always pass either obj[:0] or the
328
323
# safer obj._get_values(slice(None, 0))
@@ -446,14 +441,13 @@ cdef class Slider:
446
441
Py_ssize_t stride, orig_len, orig_stride
447
442
char * orig_data
448
443
449
- def __init__ (self , object values , object buf ):
450
- assert (values.ndim == 1 )
444
+ def __init__ (self , ndarray values , ndarray buf ):
445
+ assert values.ndim == 1
446
+ assert values.dtype == buf.dtype
451
447
452
- if util.is_array(values) and not values.flags.contiguous:
453
- # e.g. Categorical has no `flags` attribute
448
+ if not values.flags.contiguous:
454
449
values = values.copy()
455
450
456
- assert (values.dtype == buf.dtype)
457
451
self .values = values
458
452
self .buf = buf
459
453
self .stride = values.strides[0 ]
0 commit comments