I would rather have more informative error message such as:

```python

input_type = X.format if sp.issparse(X) else type(X)
raise TypeError("Expected a CSR or CSC sparse matrix, got %s." % input_type)
```