File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -4252,16 +4252,15 @@ def equals(self, other: Any) -> bool:
4252
4252
if not isinstance (other , Index ):
4253
4253
return False
4254
4254
4255
- if is_object_dtype (self .dtype ) and not is_object_dtype (other .dtype ):
4256
- # if other is not object, use other's logic for coercion
4257
- return other .equals (self )
4258
-
4259
- if isinstance (other , ABCMultiIndex ):
4260
- # d-level MultiIndex can equal d-tuple Index
4261
- return other .equals (self )
4262
-
4263
- if is_extension_array_dtype (other .dtype ):
4264
- # All EA-backed Index subclasses override equals
4255
+ # If other is a subclass of self and defines it's own equals method, we
4256
+ # dispatch to the subclass method. For instance for a MultiIndex,
4257
+ # a d-level MultiIndex can equal d-tuple Index.
4258
+ # Note: All EA-backed Index subclasses override equals
4259
+ if (
4260
+ isinstance (other , type (self ))
4261
+ and type (other ) is not type (self )
4262
+ and other .equals is not self .equals
4263
+ ):
4265
4264
return other .equals (self )
4266
4265
4267
4266
return array_equivalent (self ._values , other ._values )
You can’t perform that action at this time.
0 commit comments