Skip to content

Commit a68826d

Browse files
committed
revert Index.__rsub__
1 parent c5fdf53 commit a68826d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pandas/core/indexes/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,10 +2267,6 @@ def __sub__(self, other):
22672267
raise TypeError("cannot perform __sub__ with this index type: "
22682268
"{typ}".format(typ=type(self).__name__))
22692269

2270-
def __rsub__(self, other):
2271-
# TODO: name etc? __radd__ doesn't pass it.
2272-
return Index(other - np.array(self))
2273-
22742270
def __and__(self, other):
22752271
return self.intersection(other)
22762272

pandas/tests/indexes/test_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,9 @@ def test_ensure_index_from_sequences(self, data, names, expected):
23082308
'pow', 'rpow', 'mod', 'divmod'])
23092309
def test_generated_op_names(opname, indices):
23102310
index = indices
2311+
if type(index) is pd.Index and opname == 'rsub':
2312+
# method doesn't exist, see GH#19723
2313+
return
23112314
opname = '__{name}__'.format(name=opname)
23122315
method = getattr(index, opname)
23132316
assert method.__name__ == opname

0 commit comments

Comments
 (0)