def __getitem__(self, pargs):
if len(self.shape) == <NUM_LIT:2>:<EOL><INDENT>numrows, numcols = self.shape<EOL>numbands = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>numrows, numcols, numbands = self.shape<EOL><DEDENT>if isinstance(pargs, int):<EOL><INDENT>row = pargs<EOL>area = (row, <NUM_LIT:0>, row + <NUM_LIT:1>, numcols)<EOL>return self._read(area=area).squeeze()<EOL><DEDENT>if pargs is Ellipsis:<EOL><INDENT>return self._read()<EOL><DEDENT>if isinstance(pargs, slice):<EOL><INDENT>if (((pargs.start is None) and<EOL>(pargs.stop is None) and<EOL>(pargs.step is None))):<EOL><INDENT>return self._read()<EOL><DEDENT>pargs = (pargs, Ellipsis)<EOL><DEDENT>if isinstance(pargs, tuple) and any(x is Ellipsis for x in pargs):<EOL><INDENT>newindex = self._remove_ellipsis(pargs, numrows, numcols, numbands)<EOL>return self.__getitem__(newindex)<EOL><DEDENT>if isinstance(pargs, tuple) and any(isinstance(x, int) for x in pargs):<EOL><INDENT>lst = list(pargs)<EOL>g = filterfalse(lambda x: not isinstance(x[<NUM_LIT:1>], int),<EOL>enumerate(pargs))<EOL>idx = next(g)[<NUM_LIT:0>]<EOL>lst[idx] = slice(pargs[idx], pargs[idx] + <NUM_LIT:1>)<EOL>newindex = tuple(lst)<EOL>data = self.__getitem__(newindex)<EOL>return np.squeeze(data, axis=idx)<EOL><DEDENT>rows = pargs[<NUM_LIT:0>]<EOL>cols = pargs[<NUM_LIT:1>]<EOL>if len(pargs) == <NUM_LIT:2>:<EOL><INDENT>bands = slice(None, None, None)<EOL><DEDENT>else:<EOL><INDENT>bands = pargs[<NUM_LIT:2>]<EOL><DEDENT>rows_step = <NUM_LIT:1> if rows.step is None else rows.step<EOL>cols_step = <NUM_LIT:1> if cols.step is None else cols.step<EOL>if rows_step != cols_step:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise IndexError(msg)<EOL><DEDENT>step = rows_step<EOL>if np.abs(np.log2(step) - np.round(np.log2(step))) > <NUM_LIT>:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise IndexError(msg)<EOL><DEDENT>rlevel = np.int(np.round(np.log2(step)))<EOL>area = (<NUM_LIT:0> if rows.start is None else rows.start,<EOL><NUM_LIT:0> if cols.start is None else cols.start,<EOL>numrows if rows.stop is None else rows.stop,<EOL>numcols if cols.stop is None else cols.stop<EOL>)<EOL>data = self._read(area=area, rlevel=rlevel)<EOL>if len(pargs) == <NUM_LIT:2>:<EOL><INDENT>return data<EOL><DEDENT>return data[:, :, bands]<EOL>
Slicing protocol.