@@ -20,21 +20,17 @@ def test_set_ops_error_cases(idx, case, sort, method):
20
20
21
21
@pytest .mark .parametrize ("sort" , [None , False ])
22
22
def test_intersection_base (idx , sort ):
23
- first = idx [:5 ]
24
- second = idx [:3 ]
25
- intersect = first .intersection (second , sort = sort )
26
-
27
- if sort is None :
28
- tm .assert_index_equal (intersect , second .sort_values ())
29
- assert tm .equalContents (intersect , second )
23
+ first = idx [2 ::- 1 ] # first 3 elements reversed
24
+ second = idx [:5 ]
30
25
31
- # GH 10149
32
- cases = [klass (second .values ) for klass in [np .array , Series , list ]]
33
- for case in cases :
34
- result = first .intersection (case , sort = sort )
26
+ array_like_cases = [klass (second .values ) for klass in [np .array , Series , list ]]
27
+ for case in [second , * array_like_cases ]:
28
+ intersect = first .intersection (case , sort = sort )
35
29
if sort is None :
36
- tm .assert_index_equal (result , second .sort_values ())
37
- assert tm .equalContents (result , second )
30
+ expected = first .sort_values ()
31
+ else :
32
+ expected = first
33
+ tm .assert_index_equal (intersect , expected )
38
34
39
35
msg = "other must be a MultiIndex or a list of tuples"
40
36
with pytest .raises (TypeError , match = msg ):
0 commit comments