Coming late to the party but it would be nice to report the actual type of sparse matrix with `X.getformat()` in the error message.