def __getitem__(self, key):
super_getitem = super().__getitem__<EOL>if is_scalar(key):<EOL><INDENT>if not lib.is_integer(key):<EOL><INDENT>raise IndexError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>n = com.cast_scalar_indexer(key)<EOL>if n != key:<EOL><INDENT>return super_getitem(key)<EOL><DEDENT>if n < <NUM_LIT:0>:<EOL><INDENT>n = len(self) + key<EOL><DEDENT>if n < <NUM_LIT:0> or n > len(self) - <NUM_LIT:1>:<EOL><INDENT>raise IndexError("<STR_LIT>"<EOL>"<STR_LIT>".format(key=key,<EOL>size=len(self)))<EOL><DEDENT>return self._start + n * self._step<EOL><DEDENT>if isinstance(key, slice):<EOL><INDENT>length = len(self)<EOL>step = <NUM_LIT:1> if key.step is None else key.step<EOL>if key.start is None:<EOL><INDENT>start = length - <NUM_LIT:1> if step < <NUM_LIT:0> else <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>start = key.start<EOL>if start < <NUM_LIT:0>:<EOL><INDENT>start += length<EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start = -<NUM_LIT:1> if step < <NUM_LIT:0> else <NUM_LIT:0><EOL><DEDENT>if start >= length:<EOL><INDENT>start = length - <NUM_LIT:1> if step < <NUM_LIT:0> else length<EOL><DEDENT><DEDENT>if key.stop is None:<EOL><INDENT>stop = -<NUM_LIT:1> if step < <NUM_LIT:0> else length<EOL><DEDENT>else:<EOL><INDENT>stop = key.stop<EOL>if stop < <NUM_LIT:0>:<EOL><INDENT>stop += length<EOL><DEDENT>if stop < <NUM_LIT:0>:<EOL><INDENT>stop = -<NUM_LIT:1><EOL><DEDENT>if stop > length:<EOL><INDENT>stop = length<EOL><DEDENT><DEDENT>if (start != int(start) or<EOL>stop != int(stop) or<EOL>step != int(step)):<EOL><INDENT>return super_getitem(key)<EOL><DEDENT>start = self._start + self._step * start<EOL>stop = self._start + self._step * stop<EOL>step = self._step * step<EOL>return RangeIndex._simple_new(start, stop, step, name=self.name)<EOL><DEDENT>return super_getitem(key)<EOL>
Conserve RangeIndex type for scalar and slice keys.