Reputation: 3854
Mat_A[:,0 ] = np.ravel(Mat_A.sum(axis=0)) TypeError: coo_matrix' object does not support item assignment
weights
befor going to sparse space?Mat_A = sparse.coo_matrix((weights, (i_indices_O, j_indices_O)), shape=(pixel_nb_O, pixel_nb_O))
Mat_A[:,0 ] = np.ravel(Mat_A.sum(axis=0))
Mat_A[:,1:] = 0
Mat_A = Mat_A.tocsr()
Upvotes: 0
Views: 915
Reputation: 88246
coo_matrix
's sparse format comes with some disadvantages, which are well mentioned in the docs:
does not directly support:
- arithmetic operations
- slicing
COO
is a fast format for constructing sparse matrices, though for arithmetic operations you should switch to CSR
or CSC
.
Upvotes: 3