I have a sparse matrix A in python. I m going through code of a friend of mine and he uses A[:,i:i+1].toarray().flatten() in his code. As far as I m concerned, the program worked for him. However when I try to use it, I get:
from scipy import sparse
...
diagonals = [[2] * 3, [-1] * (3-1), [-1] * (3-1)]
offsets = [0, 1, -1]
B = sparse.diags(diagonals, offsets)
A = sparse.kronsum(B,B)
...
A[:,i:i+1].toarray().flatten()
Exception:
in __getitem__
raise NotImplementedError
NotImplementedError
My question, what to I need to implement or how could I access elements of a sparse matrix. Thanks for the help.