[SciPy-dev] Ideas for scipy.sparse?

Nathan Bell wnbell@gmail....
Fri Apr 18 19:26:59 CDT 2008

On Tue, Apr 15, 2008 at 11:59 AM, Viral Shah
<vshah@interactivesupercomputing.com> wrote:
>  Perhaps it is a good idea to document the reverse process of
>  extracting indices from coo_matrix as well ? Currently, it only
>  provides a way to construct a matrix from indices and not the other
>  way around, which is equally useful, like Nathan said in the last email.
>  A = coo_matrix(A)
>  I,J,V = A.row,A.col,A.data

We could make a function scipy.sparse.find() to match MATLAB's find()

def find(A):
    A = coo_matrix(A, copy=True)
    return A.row, A.col, A.data

The copy=True ensures that the result arrays are distinct from A's
data when A is a coo_matrix.  We could then add sparse.find() to the
table of MATLAB equivalences.

Nathan Bell wnbell@gmail.com

More information about the Scipy-dev mailing list