Also please add tests for other formats in a loop:

```python
for sp_matrix in [csr_matrix, csc_matrix, coo_matrix]:
    X_sparse = sp_matrix(Xdigits)
    ...
```

If that fails, you need to convert any sparse matrix to CSR before slicing internally.