def _get_submatrix(self, row_slice, col_slice):
M,N = self.shape<EOL>def process_slice(sl, num):<EOL><INDENT>if isinstance(sl, slice):<EOL><INDENT>if sl.step not in (<NUM_LIT:1>, None):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>i0, i1 = sl.start, sl.stop<EOL>if i0 is None:<EOL><INDENT>i0 = <NUM_LIT:0><EOL><DEDENT>elif i0 < <NUM_LIT:0>:<EOL><INDENT>i0 = num + i0<EOL><DEDENT>if i1 is None:<EOL><INDENT>i1 = num<EOL><DEDENT>elif i1 < <NUM_LIT:0>:<EOL><INDENT>i1 = num + i1<EOL><DEDENT>return i0, i1<EOL><DEDENT>elif isintlike(sl):<EOL><INDENT>if sl < <NUM_LIT:0>:<EOL><INDENT>sl += num<EOL><DEDENT>return sl, sl + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT>def check_bounds(i0, i1, num):<EOL><INDENT>if not (<NUM_LIT:0> <= i0 <= num) or not (<NUM_LIT:0> <= i1 <= num) or not (i0 <= i1):<EOL><INDENT>raise IndexError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (i0, num, i1, num, i0, i1))<EOL><DEDENT><DEDENT>i0, i1 = process_slice(row_slice, M)<EOL>j0, j1 = process_slice(col_slice, N)<EOL>check_bounds(i0, i1, M)<EOL>check_bounds(j0, j1, N)<EOL>indptr, indices, data = get_csr_submatrix(M, N,<EOL>self.indptr, self.indices, self.data,<EOL>int(i0), int(i1), int(j0), int(j1))<EOL>shape = (i1 - i0, j1 - j0)<EOL>return self.__class__((data,indices,indptr), shape=shape)<EOL>
Return a submatrix of this matrix (new matrix is created).