Are you sure you don't want to use boolean indexing before doing `.reduceat`? Lines 118 through 125 can be rewritten more compactly, probably also faster, and I think more readable, as:

```
nnz = np.diff(indptr)
# look only at rows with non-zero entries
mask = nnz > 0
# compute min_or_max of non-zero entries in each row
min_or_max.reduceat(mat.data, indptr[mask], 0, None, out[mask]) 
# the min_or_max of non-full rows may be zero
mask &= nnz < N
out[mask] = min_or_max(out[mask], zero)
```