Sparse matrix prep

Implement python version for sparse
or a work-around for the last part