Skip to content

Commit 7f06248

Browse files
committed
reverse MI equivalence with tuple
1 parent 9876d8f commit 7f06248

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

pandas/indexes/multi.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2217,9 +2217,7 @@ def equals(self, other):
22172217
return True
22182218

22192219
if not isinstance(other, Index):
2220-
if not isinstance(other, tuple):
2221-
return False
2222-
other = Index([other])
2220+
return False
22232221

22242222
if not isinstance(other, MultiIndex):
22252223
return array_equivalent(self._values,

pandas/src/hashtable_class_helper.pxi.in

+3
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ cdef class MultiIndexHashTable(HashTable):
881881
if (alocs != -1).all():
882882

883883
result = self.mi.take(locs)
884+
if isinstance(mi, tuple):
885+
from pandas import Index
886+
mi = Index([mi])
884887
if not result.equals(mi):
885888
raise AssertionError(
886889
"hash collision\nlocs:\n{}\n"

pandas/tests/indexes/test_multi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1504,9 +1504,9 @@ def test_equals_missing_values(self):
15041504
i = pd.MultiIndex.from_tuples([(0, pd.NaT),
15051505
(0, pd.Timestamp('20130101'))])
15061506
result = i[0:1].equals(i[0])
1507-
self.assertTrue(result)
1507+
self.assertFalse(result)
15081508
result = i[1:2].equals(i[1])
1509-
self.assertTrue(result)
1509+
self.assertFalse(result)
15101510

15111511
def test_identical(self):
15121512
mi = self.index.copy()

0 commit comments

Comments
 (0)