@@ -765,6 +765,11 @@ def test_intersect_str_dates(self, sort):
765
765
766
766
assert len (result ) == 0
767
767
768
+ def test_intersect_nosort (self ):
769
+ result = pd .Index (['c' , 'b' , 'a' ]).intersection (['b' , 'a' ])
770
+ expected = pd .Index (['b' , 'a' ])
771
+ tm .assert_index_equal (result , expected )
772
+
768
773
@pytest .mark .parametrize ("sort" , [True , False ])
769
774
def test_chained_union (self , sort ):
770
775
# Chained unions handles names correctly
@@ -1595,20 +1600,27 @@ def test_drop_tuple(self, values, to_drop):
1595
1600
for drop_me in to_drop [1 ], [to_drop [1 ]]:
1596
1601
pytest .raises (KeyError , removed .drop , drop_me )
1597
1602
1598
- @pytest .mark .parametrize ("method,expected" , [
1603
+ @pytest .mark .parametrize ("method,expected,sort" , [
1604
+ ('intersection' , np .array ([(1 , 'A' ), (2 , 'A' ), (1 , 'B' ), (2 , 'B' )],
1605
+ dtype = [('num' , int ), ('let' , 'a1' )]),
1606
+ False ),
1607
+
1599
1608
('intersection' , np .array ([(1 , 'A' ), (1 , 'B' ), (2 , 'A' ), (2 , 'B' )],
1600
- dtype = [('num' , int ), ('let' , 'a1' )])),
1609
+ dtype = [('num' , int ), ('let' , 'a1' )]),
1610
+ True ),
1611
+
1601
1612
('union' , np .array ([(1 , 'A' ), (1 , 'B' ), (1 , 'C' ), (2 , 'A' ), (2 , 'B' ),
1602
- (2 , 'C' )], dtype = [('num' , int ), ('let' , 'a1' )]))
1613
+ (2 , 'C' )], dtype = [('num' , int ), ('let' , 'a1' )]),
1614
+ True )
1603
1615
])
1604
- def test_tuple_union_bug (self , method , expected ):
1616
+ def test_tuple_union_bug (self , method , expected , sort ):
1605
1617
index1 = Index (np .array ([(1 , 'A' ), (2 , 'A' ), (1 , 'B' ), (2 , 'B' )],
1606
1618
dtype = [('num' , int ), ('let' , 'a1' )]))
1607
1619
index2 = Index (np .array ([(1 , 'A' ), (2 , 'A' ), (1 , 'B' ),
1608
1620
(2 , 'B' ), (1 , 'C' ), (2 , 'C' )],
1609
1621
dtype = [('num' , int ), ('let' , 'a1' )]))
1610
1622
1611
- result = getattr (index1 , method )(index2 )
1623
+ result = getattr (index1 , method )(index2 , sort = sort )
1612
1624
assert result .ndim == 1
1613
1625
1614
1626
expected = Index (expected )
0 commit comments