@@ -220,7 +220,7 @@ def group_mean_{{name}}(ndarray[{{c_type}}, ndim=2] out,
220
220
221
221
@cython.wraparound(False)
222
222
@cython.boundscheck(False)
223
- def group_ohlc_{{name}}(ndarray[ {{c_type}}, ndim=2 ] out,
223
+ def group_ohlc_{{name}}({{c_type}}[:, : ] out,
224
224
int64_t[:] counts,
225
225
ndarray[{{c_type}}, ndim=2] values,
226
226
int64_t[:] labels,
@@ -246,7 +246,8 @@ def group_ohlc_{{name}}(ndarray[{{c_type}}, ndim=2] out,
246
246
if K > 1:
247
247
raise NotImplementedError("Argument 'values' must have only "
248
248
"one dimension")
249
- out.fill(np.nan)
249
+
250
+ out[:] = np.nan
250
251
251
252
with nogil:
252
253
for i in range(N):
@@ -304,16 +305,16 @@ def group_last_{{name}}(ndarray[{{c_type}}, ndim=2] out,
304
305
cdef:
305
306
Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
306
307
{{c_type}} val
307
- ndarray[ {{c_type}}, ndim=2 ] resx
308
- ndarray[ int64_t, ndim=2 ] nobs
308
+ {{c_type}}[:, : ] resx
309
+ int64_t[:, : ] nobs
309
310
310
311
assert min_count == -1, "'min_count' only used in add and prod"
311
312
312
313
if not len(values) == len(labels):
313
314
raise AssertionError("len(index) != len(labels)")
314
315
315
316
nobs = np.zeros((<object> out).shape, dtype=np.int64)
316
- {{if name== 'object'}}
317
+ {{if name == 'object'}}
317
318
resx = np.empty((<object> out).shape, dtype=object)
318
319
{{else}}
319
320
resx = np.empty_like(out)
@@ -361,8 +362,8 @@ def group_nth_{{name}}(ndarray[{{c_type}}, ndim=2] out,
361
362
cdef:
362
363
Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
363
364
{{c_type}} val
364
- ndarray[ {{c_type}}, ndim=2 ] resx
365
- ndarray[ int64_t, ndim=2 ] nobs
365
+ {{c_type}}[:, : ] resx
366
+ int64_t[:, : ] nobs
366
367
367
368
assert min_count == -1, "'min_count' only used in add and prod"
368
369
@@ -411,7 +412,7 @@ def group_nth_{{name}}(ndarray[{{c_type}}, ndim=2] out,
411
412
412
413
@cython.boundscheck(False)
413
414
@cython.wraparound(False)
414
- def group_rank_{{name}}(ndarray[ float64_t, ndim=2 ] out,
415
+ def group_rank_{{name}}(float64_t[:, : ] out,
415
416
ndarray[{{c_type}}, ndim=2] values,
416
417
ndarray[int64_t] labels,
417
418
bint is_datetimelike, object ties_method,
@@ -453,8 +454,8 @@ def group_rank_{{name}}(ndarray[float64_t, ndim=2] out,
453
454
TiebreakEnumType tiebreak
454
455
Py_ssize_t i, j, N, K, grp_start=0, dups=0, sum_ranks=0
455
456
Py_ssize_t grp_vals_seen=1, grp_na_count=0, grp_tie_count=0
456
- ndarray[ int64_t] _as
457
- ndarray[ float64_t, ndim=2 ] grp_sizes
457
+ int64_t[: ] _as
458
+ float64_t[:, : ] grp_sizes
458
459
ndarray[{{c_type}}] masked_vals
459
460
ndarray[uint8_t] mask
460
461
bint keep_na
@@ -617,7 +618,7 @@ def group_max(ndarray[groupby_t, ndim=2] out,
617
618
cdef:
618
619
Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
619
620
groupby_t val, count, nan_val
620
- ndarray[ groupby_t, ndim=2 ] maxx, nobs
621
+ groupby_t[:, : ] maxx, nobs
621
622
622
623
assert min_count == -1, "'min_count' only used in add and prod"
623
624
@@ -629,10 +630,10 @@ def group_max(ndarray[groupby_t, ndim=2] out,
629
630
maxx = np.empty_like(out)
630
631
if groupby_t is int64_t:
631
632
# Note: evaluated at compile-time
632
- maxx.fill( -_int64_max)
633
+ maxx[:] = -_int64_max
633
634
nan_val = iNaT
634
635
else:
635
- maxx.fill( -np.inf)
636
+ maxx[:] = -np.inf
636
637
nan_val = NAN
637
638
638
639
N, K = (<object> values).shape
@@ -685,7 +686,7 @@ def group_min(ndarray[groupby_t, ndim=2] out,
685
686
cdef:
686
687
Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
687
688
groupby_t val, count, nan_val
688
- ndarray[ groupby_t, ndim=2 ] minx, nobs
689
+ groupby_t[:, : ] minx, nobs
689
690
690
691
assert min_count == -1, "'min_count' only used in add and prod"
691
692
@@ -696,10 +697,10 @@ def group_min(ndarray[groupby_t, ndim=2] out,
696
697
697
698
minx = np.empty_like(out)
698
699
if groupby_t is int64_t:
699
- minx.fill( _int64_max)
700
+ minx[:] = _int64_max
700
701
nan_val = iNaT
701
702
else:
702
- minx.fill( np.inf)
703
+ minx[:] = np.inf
703
704
nan_val = NAN
704
705
705
706
N, K = (<object> values).shape
@@ -741,7 +742,7 @@ group_min_int64 = group_min["int64_t"]
741
742
742
743
@cython.boundscheck(False)
743
744
@cython.wraparound(False)
744
- def group_cummin(ndarray[ groupby_t, ndim=2 ] out,
745
+ def group_cummin(groupby_t[:, : ] out,
745
746
ndarray[groupby_t, ndim=2] values,
746
747
ndarray[int64_t] labels,
747
748
bint is_datetimelike):
@@ -751,15 +752,15 @@ def group_cummin(ndarray[groupby_t, ndim=2] out,
751
752
cdef:
752
753
Py_ssize_t i, j, N, K, size
753
754
groupby_t val, mval
754
- ndarray[ groupby_t, ndim=2 ] accum
755
+ groupby_t[:, : ] accum
755
756
int64_t lab
756
757
757
758
N, K = (<object> values).shape
758
759
accum = np.empty_like(values)
759
760
if groupby_t is int64_t:
760
- accum.fill( _int64_max)
761
+ accum[:] = _int64_max
761
762
else:
762
- accum.fill( np.inf)
763
+ accum[:] = np.inf
763
764
764
765
with nogil:
765
766
for i in range(N):
@@ -794,7 +795,7 @@ group_cummin_int64 = group_cummin["int64_t"]
794
795
795
796
@cython.boundscheck(False)
796
797
@cython.wraparound(False)
797
- def group_cummax(ndarray[ groupby_t, ndim=2 ] out,
798
+ def group_cummax(groupby_t[:, : ] out,
798
799
ndarray[groupby_t, ndim=2] values,
799
800
ndarray[int64_t] labels,
800
801
bint is_datetimelike):
@@ -804,15 +805,15 @@ def group_cummax(ndarray[groupby_t, ndim=2] out,
804
805
cdef:
805
806
Py_ssize_t i, j, N, K, size
806
807
groupby_t val, mval
807
- ndarray[ groupby_t, ndim=2 ] accum
808
+ groupby_t[:, : ] accum
808
809
int64_t lab
809
810
810
811
N, K = (<object> values).shape
811
812
accum = np.empty_like(values)
812
813
if groupby_t is int64_t:
813
- accum.fill( -_int64_max)
814
+ accum[:] = -_int64_max
814
815
else:
815
- accum.fill( -np.inf)
816
+ accum[:] = -np.inf
816
817
817
818
with nogil:
818
819
for i in range(N):
0 commit comments