File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -135,9 +135,8 @@ cdef class Reducer:
135
135
else :
136
136
res = self .f(chunk)
137
137
138
- if (not _is_sparse_array(res) and hasattr (res, ' values' )
139
- and util.is_array(res.values)):
140
- res = res.values
138
+ # TODO: reason for not squeezing here?
139
+ res = _extract_result(res, squeeze = False )
141
140
if i == 0 :
142
141
# On the first pass, we check the output shape to see
143
142
# if this looks like a reduction.
@@ -402,18 +401,17 @@ cdef class SeriesGrouper(_BaseGrouper):
402
401
return result, counts
403
402
404
403
405
- cdef inline _extract_result(object res):
404
+ cdef inline _extract_result(object res, bint squeeze = True ):
406
405
""" extract the result object, it might be a 0-dim ndarray
407
406
or a len-1 0-dim, or a scalar """
408
407
if (not _is_sparse_array(res) and hasattr (res, ' values' )
409
408
and util.is_array(res.values)):
410
409
res = res.values
411
- if not np.isscalar(res):
412
- if util.is_array(res):
413
- if res.ndim == 0 :
414
- res = res.item()
415
- elif res.ndim == 1 and len (res) == 1 :
416
- res = res[0 ]
410
+ if util.is_array(res):
411
+ if res.ndim == 0 :
412
+ res = res.item()
413
+ elif squeeze and res.ndim == 1 and len (res) == 1 :
414
+ res = res[0 ]
417
415
return res
418
416
419
417
You can’t perform that action at this time.
0 commit comments