|
6 | 6 | import numpy as np |
7 | 7 |
|
8 | 8 | from pandas._libs import index as libindex |
| 9 | +from pandas._libs import lib |
9 | 10 | import pandas.compat as compat |
10 | 11 | from pandas.compat import get_range_parameters, lrange, range |
11 | 12 | from pandas.compat.numpy import function as nv |
@@ -502,7 +503,12 @@ def __getitem__(self, key): |
502 | 503 | super_getitem = super(RangeIndex, self).__getitem__ |
503 | 504 |
|
504 | 505 | if is_scalar(key): |
505 | | - n = int(key) |
| 506 | + if not lib.is_integer(key): |
| 507 | + raise IndexError("only integers, slices (`:`), " |
| 508 | + "ellipsis (`...`), numpy.newaxis (`None`) " |
| 509 | + "and integer or boolean " |
| 510 | + "arrays are valid indices") |
| 511 | + n = com.cast_scalar_indexer(key) |
506 | 512 | if n != key: |
507 | 513 | return super_getitem(key) |
508 | 514 | if n < 0: |
@@ -653,7 +659,8 @@ def _evaluate_numeric_binop(self, other): |
653 | 659 | return op(self._int64index, other) |
654 | 660 | # TODO: Do attrs get handled reliably? |
655 | 661 |
|
656 | | - return _evaluate_numeric_binop |
| 662 | + name = '__{name}__'.format(name=op.__name__) |
| 663 | + return compat.set_function_name(_evaluate_numeric_binop, name, cls) |
657 | 664 |
|
658 | 665 | cls.__add__ = _make_evaluate_binop(operator.add) |
659 | 666 | cls.__radd__ = _make_evaluate_binop(ops.radd) |
|
0 commit comments