from scipy.sparse import hstack
from scipy.sparse.linalg import svds

def tls(A, b, k=6):
    """A tls solution of Ax= b, for sparse A."""
u, s, v = svds(hstack([A, b]), k)
return v[(-1), :-1] / -v[-1, -1]
pseudo inverse of sparse matrix in python