@@ -9,7 +9,7 @@ cdef extern from "numpy/npy_math.h":
99_int64_max = np.iinfo(np.int64).max
1010
1111# ----------------------------------------------------------------------
12- # group_add, group_prod, group_var, group_mean, group_ohlc
12+ # group_prod, group_var, group_mean, group_ohlc
1313# ----------------------------------------------------------------------
1414
1515{{py:
@@ -27,53 +27,6 @@ def get_dispatch(dtypes):
2727{{for name, c_type in get_dispatch(dtypes)}}
2828
2929
30- @cython.wraparound(False)
31- @cython.boundscheck(False)
32- def group_add_{{name}}({{c_type}}[:, :] out,
33- int64_t[:] counts,
34- {{c_type}}[:, :] values,
35- const int64_t[:] labels,
36- Py_ssize_t min_count=0):
37- """
38- Only aggregates on axis=0
39- """
40- cdef:
41- Py_ssize_t i, j, N, K, lab, ncounts = len(counts)
42- {{c_type}} val, count
43- ndarray[{{c_type}}, ndim=2] sumx, nobs
44-
45- if not len(values) == len(labels):
46- raise AssertionError("len(index) != len(labels)")
47-
48- nobs = np.zeros_like(out)
49- sumx = np.zeros_like(out)
50-
51- N, K = (<object>values).shape
52-
53- with nogil:
54-
55- for i in range(N):
56- lab = labels[i]
57- if lab < 0:
58- continue
59-
60- counts[lab] += 1
61- for j in range(K):
62- val = values[i, j]
63-
64- # not nan
65- if val == val:
66- nobs[lab, j] += 1
67- sumx[lab, j] += val
68-
69- for i in range(ncounts):
70- for j in range(K):
71- if nobs[i, j] < min_count:
72- out[i, j] = NAN
73- else:
74- out[i, j] = sumx[i, j]
75-
76-
7730@cython.wraparound(False)
7831@cython.boundscheck(False)
7932def group_prod_{{name}}({{c_type}}[:, :] out,
0 commit comments