python implementation of sparse coding