data = out_mat.data[0]
for i, (start, stop) in enumerate(izip(mat.indptr, mat.indptr[1:])):
if start == stop:
continue
val = min_or_max(mat.data[start:stop])
if stop - start < N:
val = min_or_max([0, val])
data.append(val)
row.append(i)
if axis == 1:
out_mat = out_mat.tocsr().T
After Change
mat = self.tocsc() if axis == 0 else self.tocsr()
mat.sum_duplicates()
indptr = mat.indptr
zero = self.dtype.type(0)
out = np.zeros(len(indptr) - 1, dtype=self.dtype)
// can"t use indices > data length with reduceat`
trunc = np.searchsorted(indptr, indptr[-1])
min_or_max.reduceat(mat.data, indptr[:trunc], out=out[:trunc])
nnz = np.diff(indptr)
min_or_max(out, zero, where=nnz < N, out=out)
out[nnz == 0] = zero