'Return a submatrix of this matrix (new matrix is created).'

def _get_submatrix(self, row_slice, col_slice):

    def process_slice(sl, num):
        if isinstance(sl, slice):
            (i0, i1, stride) = sl.indices(num)
            if (stride != 1):
                raise ValueError('slicing    with    step    !=    1    not    supported')
        elif isintlike(sl):
            if (sl < 0):
                sl += num
            (i0, i1) = (sl, (sl + 1))
        else:
            raise TypeError('expected    slice    or    scalar')
        if ((not (0 <= i0 <= num)) or (not (0 <= i1 <= num)) or (not (i0 <= i1))):
            raise IndexError(('index    out    of    bounds:    0    <=    %d    <=    %d,    0    <=    %d    <=    %d,    %d    <=    %d' % (i0, num, i1, num, i0, i1)))
        return (i0, i1)
    (M, N) = self.shape
    (i0, i1) = process_slice(row_slice, M)
    (j0, j1) = process_slice(col_slice, N)
    (indptr, indices, data) = get_csr_submatrix(M, N, self.indptr, self.indices, self.data, i0, i1, j0, j1)
    shape = ((i1 - i0), (j1 - j0))
    return self.__class__((data, indices, indptr), shape=shape, dtype=self.dtype, copy=False)
