Closed KikeM closed 3 years ago
El problema está en csr_matrix.data
, no es equivalente con lo que devuelve scipy.sparse.find
:
from scipy.sparse import csr_matrix, find
A = csr_matrix(
[
[7.0, 8.0, 0.0],
[-2.0, 0.0, 9.0],
[0.0, 0.0, 9.0],
]
)
rows, cols, values = find(A)
A_rt = csr_matrix((values, (rows, cols)))
# (Pdb++) values
# array([ 7., -2., 8., 9., 9.])
# (Pdb++) A.data
# array([ 7., 8., -2., 9., 9.])
# (Pdb++) A.todense()
# matrix([[ 7., 8., 0.],
# [-2., 0., 9.],
# [ 0., 0., 9.]])
# (Pdb++) A_rt.todense()
# matrix([[ 7., 8., 0.],
# [-2., 0., 9.],
# [ 0., 0., 9.]])
.data
.
There is a bug in the determination of the rows and the columns.
Originally posted by @KikeM in https://github.com/KikeM/msc-thesis/issues/52#issuecomment-873440801