@@ -2377,31 +2377,10 @@ def _get_unique_index(self, dropna: bool = False):
2377
2377
# --------------------------------------------------------------------
2378
2378
# Arithmetic & Logical Methods
2379
2379
2380
- def __add__ (self , other ):
2381
- if isinstance (other , (ABCSeries , ABCDataFrame )):
2382
- return NotImplemented
2383
- from pandas import Series
2384
-
2385
- return Index (Series (self ) + other )
2386
-
2387
- def __radd__ (self , other ):
2388
- from pandas import Series
2389
-
2390
- return Index (other + Series (self ))
2391
-
2392
2380
def __iadd__ (self , other ):
2393
2381
# alias for __add__
2394
2382
return self + other
2395
2383
2396
- def __sub__ (self , other ):
2397
- return Index (np .array (self ) - other )
2398
-
2399
- def __rsub__ (self , other ):
2400
- # wrap Series to ensure we pin name correctly
2401
- from pandas import Series
2402
-
2403
- return Index (other - Series (self ))
2404
-
2405
2384
def __and__ (self , other ):
2406
2385
return self .intersection (other )
2407
2386
@@ -5293,38 +5272,6 @@ def _add_comparison_methods(cls):
5293
5272
cls .__le__ = _make_comparison_op (operator .le , cls )
5294
5273
cls .__ge__ = _make_comparison_op (operator .ge , cls )
5295
5274
5296
- @classmethod
5297
- def _add_numeric_methods_add_sub_disabled (cls ):
5298
- """
5299
- Add in the numeric add/sub methods to disable.
5300
- """
5301
- cls .__add__ = make_invalid_op ("__add__" )
5302
- cls .__radd__ = make_invalid_op ("__radd__" )
5303
- cls .__iadd__ = make_invalid_op ("__iadd__" )
5304
- cls .__sub__ = make_invalid_op ("__sub__" )
5305
- cls .__rsub__ = make_invalid_op ("__rsub__" )
5306
- cls .__isub__ = make_invalid_op ("__isub__" )
5307
-
5308
- @classmethod
5309
- def _add_numeric_methods_disabled (cls ):
5310
- """
5311
- Add in numeric methods to disable other than add/sub.
5312
- """
5313
- cls .__pow__ = make_invalid_op ("__pow__" )
5314
- cls .__rpow__ = make_invalid_op ("__rpow__" )
5315
- cls .__mul__ = make_invalid_op ("__mul__" )
5316
- cls .__rmul__ = make_invalid_op ("__rmul__" )
5317
- cls .__floordiv__ = make_invalid_op ("__floordiv__" )
5318
- cls .__rfloordiv__ = make_invalid_op ("__rfloordiv__" )
5319
- cls .__truediv__ = make_invalid_op ("__truediv__" )
5320
- cls .__rtruediv__ = make_invalid_op ("__rtruediv__" )
5321
- cls .__mod__ = make_invalid_op ("__mod__" )
5322
- cls .__divmod__ = make_invalid_op ("__divmod__" )
5323
- cls .__neg__ = make_invalid_op ("__neg__" )
5324
- cls .__pos__ = make_invalid_op ("__pos__" )
5325
- cls .__abs__ = make_invalid_op ("__abs__" )
5326
- cls .__inv__ = make_invalid_op ("__inv__" )
5327
-
5328
5275
@classmethod
5329
5276
def _add_numeric_methods_binary (cls ):
5330
5277
"""
@@ -5340,11 +5287,12 @@ def _add_numeric_methods_binary(cls):
5340
5287
cls .__truediv__ = _make_arithmetic_op (operator .truediv , cls )
5341
5288
cls .__rtruediv__ = _make_arithmetic_op (ops .rtruediv , cls )
5342
5289
5343
- # TODO: rmod? rdivmod?
5344
5290
cls .__mod__ = _make_arithmetic_op (operator .mod , cls )
5291
+ cls .__rmod__ = _make_arithmetic_op (ops .rmod , cls )
5345
5292
cls .__floordiv__ = _make_arithmetic_op (operator .floordiv , cls )
5346
5293
cls .__rfloordiv__ = _make_arithmetic_op (ops .rfloordiv , cls )
5347
5294
cls .__divmod__ = _make_arithmetic_op (divmod , cls )
5295
+ cls .__rdivmod__ = _make_arithmetic_op (ops .rdivmod , cls )
5348
5296
cls .__mul__ = _make_arithmetic_op (operator .mul , cls )
5349
5297
cls .__rmul__ = _make_arithmetic_op (ops .rmul , cls )
5350
5298
@@ -5504,7 +5452,7 @@ def shape(self):
5504
5452
return self ._values .shape
5505
5453
5506
5454
5507
- Index ._add_numeric_methods_disabled ()
5455
+ Index ._add_numeric_methods ()
5508
5456
Index ._add_logical_methods ()
5509
5457
Index ._add_comparison_methods ()
5510
5458
0 commit comments