@@ -6697,89 +6697,17 @@ def group_count_float32(ndarray[float32_t, ndim=2] out,
6697
6697
6698
6698
@ cython.boundscheck (False )
6699
6699
@ cython.wraparound (False )
6700
- def group_count_int8 (ndarray[float32_t , ndim = 2 ] out,
6701
- ndarray[int64_t] counts ,
6702
- ndarray[int8_t , ndim = 2 ] values,
6703
- ndarray[int64_t] labels ):
6704
- '''
6705
- Only aggregates on axis=0
6706
- '''
6707
- cdef:
6708
- Py_ssize_t i, j, lab
6709
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ]
6710
- int8_t val
6711
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6712
- dtype = np.int64)
6713
-
6714
- if len (values) != len (labels):
6715
- raise AssertionError (" len(index) != len(labels)" )
6716
-
6717
- for i in range (N):
6718
- lab = labels[i]
6719
- if lab < 0 :
6720
- continue
6721
-
6722
- counts[lab] += 1
6723
- for j in range (K):
6724
- val = values[i, j]
6725
-
6726
- # not nan
6727
- nobs[lab, j] += val == val and val != iNaT
6728
-
6729
- for i in range (len (counts)):
6730
- for j in range (K):
6731
- out[i, j] = nobs[i, j]
6732
-
6733
-
6734
- @ cython.boundscheck (False )
6735
- @ cython.wraparound (False )
6736
- def group_count_int16 (ndarray[float32_t , ndim = 2 ] out,
6737
- ndarray[int64_t] counts ,
6738
- ndarray[int16_t , ndim = 2 ] values,
6739
- ndarray[int64_t] labels ):
6740
- '''
6741
- Only aggregates on axis=0
6742
- '''
6743
- cdef:
6744
- Py_ssize_t i, j, lab
6745
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ]
6746
- int16_t val
6747
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6748
- dtype = np.int64)
6749
-
6750
- if len (values) != len (labels):
6751
- raise AssertionError (" len(index) != len(labels)" )
6752
-
6753
- for i in range (N):
6754
- lab = labels[i]
6755
- if lab < 0 :
6756
- continue
6757
-
6758
- counts[lab] += 1
6759
- for j in range (K):
6760
- val = values[i, j]
6761
-
6762
- # not nan
6763
- nobs[lab, j] += val == val and val != iNaT
6764
-
6765
- for i in range (len (counts)):
6766
- for j in range (K):
6767
- out[i, j] = nobs[i, j]
6768
-
6769
-
6770
- @ cython.boundscheck (False )
6771
- @ cython.wraparound (False )
6772
- def group_count_int32 (ndarray[float64_t , ndim = 2 ] out,
6700
+ def group_count_object (ndarray[float64_t , ndim = 2 ] out,
6773
6701
ndarray[int64_t] counts ,
6774
- ndarray[int32_t , ndim = 2 ] values,
6702
+ ndarray[object , ndim = 2 ] values,
6775
6703
ndarray[int64_t] labels ):
6776
6704
'''
6777
6705
Only aggregates on axis=0
6778
6706
'''
6779
6707
cdef:
6780
6708
Py_ssize_t i, j, lab
6781
6709
Py_ssize_t N = values.shape[0 ], K = values.shape[1 ]
6782
- int32_t val
6710
+ object val
6783
6711
ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6784
6712
dtype = np.int64)
6785
6713
@@ -6839,42 +6767,6 @@ def group_count_int64(ndarray[float64_t, ndim=2] out,
6839
6767
out[i, j] = nobs[i, j]
6840
6768
6841
6769
6842
- @ cython.boundscheck (False )
6843
- @ cython.wraparound (False )
6844
- def group_count_object (ndarray[float64_t , ndim = 2 ] out,
6845
- ndarray[int64_t] counts ,
6846
- ndarray[object , ndim = 2 ] values,
6847
- ndarray[int64_t] labels ):
6848
- '''
6849
- Only aggregates on axis=0
6850
- '''
6851
- cdef:
6852
- Py_ssize_t i, j, lab
6853
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ]
6854
- object val
6855
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6856
- dtype = np.int64)
6857
-
6858
- if len (values) != len (labels):
6859
- raise AssertionError (" len(index) != len(labels)" )
6860
-
6861
- for i in range (N):
6862
- lab = labels[i]
6863
- if lab < 0 :
6864
- continue
6865
-
6866
- counts[lab] += 1
6867
- for j in range (K):
6868
- val = values[i, j]
6869
-
6870
- # not nan
6871
- nobs[lab, j] += val == val and val != iNaT
6872
-
6873
- for i in range (len (counts)):
6874
- for j in range (K):
6875
- out[i, j] = nobs[i, j]
6876
-
6877
-
6878
6770
6879
6771
@ cython.boundscheck (False )
6880
6772
@ cython.wraparound (False )
@@ -6946,85 +6838,17 @@ def group_count_bin_float32(ndarray[float32_t, ndim=2] out,
6946
6838
6947
6839
@ cython.boundscheck (False )
6948
6840
@ cython.wraparound (False )
6949
- def group_count_bin_int8 (ndarray[float32_t , ndim = 2 ] out,
6950
- ndarray[int64_t] counts ,
6951
- ndarray[int8_t , ndim = 2 ] values,
6952
- ndarray[int64_t] bins ):
6953
- '''
6954
- Only aggregates on axis=0
6955
- '''
6956
- cdef:
6957
- Py_ssize_t i, j, ngroups
6958
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ], b = 0
6959
- int8_t val
6960
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6961
- dtype = np.int64)
6962
-
6963
- ngroups = len (bins) + (bins[len (bins) - 1 ] != N)
6964
-
6965
- for i in range (N):
6966
- while b < ngroups - 1 and i >= bins[b]:
6967
- b += 1
6968
-
6969
- counts[b] += 1
6970
- for j in range (K):
6971
- val = values[i, j]
6972
-
6973
- # not nan
6974
- nobs[b, j] += val == val and val != iNaT
6975
-
6976
- for i in range (ngroups):
6977
- for j in range (K):
6978
- out[i, j] = nobs[i, j]
6979
-
6980
-
6981
- @ cython.boundscheck (False )
6982
- @ cython.wraparound (False )
6983
- def group_count_bin_int16 (ndarray[float32_t , ndim = 2 ] out,
6984
- ndarray[int64_t] counts ,
6985
- ndarray[int16_t , ndim = 2 ] values,
6986
- ndarray[int64_t] bins ):
6987
- '''
6988
- Only aggregates on axis=0
6989
- '''
6990
- cdef:
6991
- Py_ssize_t i, j, ngroups
6992
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ], b = 0
6993
- int16_t val
6994
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
6995
- dtype = np.int64)
6996
-
6997
- ngroups = len (bins) + (bins[len (bins) - 1 ] != N)
6998
-
6999
- for i in range (N):
7000
- while b < ngroups - 1 and i >= bins[b]:
7001
- b += 1
7002
-
7003
- counts[b] += 1
7004
- for j in range (K):
7005
- val = values[i, j]
7006
-
7007
- # not nan
7008
- nobs[b, j] += val == val and val != iNaT
7009
-
7010
- for i in range (ngroups):
7011
- for j in range (K):
7012
- out[i, j] = nobs[i, j]
7013
-
7014
-
7015
- @ cython.boundscheck (False )
7016
- @ cython.wraparound (False )
7017
- def group_count_bin_int32 (ndarray[float64_t , ndim = 2 ] out,
6841
+ def group_count_bin_object (ndarray[float64_t , ndim = 2 ] out,
7018
6842
ndarray[int64_t] counts ,
7019
- ndarray[int32_t , ndim = 2 ] values,
6843
+ ndarray[object , ndim = 2 ] values,
7020
6844
ndarray[int64_t] bins ):
7021
6845
'''
7022
6846
Only aggregates on axis=0
7023
6847
'''
7024
6848
cdef:
7025
6849
Py_ssize_t i, j, ngroups
7026
6850
Py_ssize_t N = values.shape[0 ], K = values.shape[1 ], b = 0
7027
- int32_t val
6851
+ object val
7028
6852
ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
7029
6853
dtype = np.int64)
7030
6854
@@ -7080,40 +6904,6 @@ def group_count_bin_int64(ndarray[float64_t, ndim=2] out,
7080
6904
out[i, j] = nobs[i, j]
7081
6905
7082
6906
7083
- @ cython.boundscheck (False )
7084
- @ cython.wraparound (False )
7085
- def group_count_bin_object (ndarray[float64_t , ndim = 2 ] out,
7086
- ndarray[int64_t] counts ,
7087
- ndarray[object , ndim = 2 ] values,
7088
- ndarray[int64_t] bins ):
7089
- '''
7090
- Only aggregates on axis=0
7091
- '''
7092
- cdef:
7093
- Py_ssize_t i, j, ngroups
7094
- Py_ssize_t N = values.shape[0 ], K = values.shape[1 ], b = 0
7095
- object val
7096
- ndarray[int64_t, ndim= 2 ] nobs = np.zeros((out.shape[0 ], out.shape[1 ]),
7097
- dtype = np.int64)
7098
-
7099
- ngroups = len (bins) + (bins[len (bins) - 1 ] != N)
7100
-
7101
- for i in range (N):
7102
- while b < ngroups - 1 and i >= bins[b]:
7103
- b += 1
7104
-
7105
- counts[b] += 1
7106
- for j in range (K):
7107
- val = values[i, j]
7108
-
7109
- # not nan
7110
- nobs[b, j] += val == val and val != iNaT
7111
-
7112
- for i in range (ngroups):
7113
- for j in range (K):
7114
- out[i, j] = nobs[i, j]
7115
-
7116
-
7117
6907
7118
6908
@ cython.wraparound (False )
7119
6909
@ cython.boundscheck (False )
0 commit comments