Oh. I didn't see that last comment :s I'll need to change a few things!


On 28 January 2014 21:02, Pauli Virtanen <notifications@github.com> wrote:

>  In scipy/sparse/data.py:
>
> > -            zero = self.dtype.type(0)
> > -            for i in range(self.shape[0]):
> > -                ith_row_data_indices = np.argwhere(mat.indices == i)
> > -                ith_row_data = mat.data[ith_row_data_indices]
> > -
> > -                # Add a zero if needed
> > -                if len(ith_row_data) < self.shape[1]:
> > -                    ith_row_data = np.append(zero, ith_row_data)
> > -
> > -                get_min_or_max = getattr(ith_row_data, min_or_max)
> > -                out_mat[i, 0] = get_min_or_max()
> > -            return self.__class__(out_mat)
> > +        min_or_max = getattr(np, min_or_max)
> > +        mat = self.tocsc() if axis == 0 else self.tocsr()
> > +        mat.sum_duplicates()
> > +        N = mat.shape[axis]
>
> Numpy seems to allow reductions as long as the axis reduced over is
> nonzero:
> np.max(np.zeros((0, 5)), axis=1)
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/scipy/scipy/pull/3248/files#r9222101>
> .
>