Skip to content

computing std of sparse matrix produces an error #8280

@vttrifonov

Description

@vttrifonov

The following code raises an error

import dask.array as da
import sparse
import numpy as np
x = da.from_array(sparse.random((10, 10), nnz=20, data_rvs=np.random.random))
x.std(axis=0).compute()

The current issue is that dask.array.reductions.moment_agg has a line denominator[denominator < 0] = np.nan, but in this case denominator is a sp.COO matrix which does not allow item assignment. A possible solution is to use denominator = np.where(denominator<0, np.nan, denominator) instead of the direct assignment .

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrayneeds attentionIt's been a while since this was pushed on. Needs attention from the owner or a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions