@@ -21,20 +21,14 @@ def test_join_non_unique(self):
2121 tm .assert_numpy_array_equal (ridx , exp_ridx )
2222
2323 def test_join_inner (self ):
24- index = Index (range (0 , 20 , 2 ), dtype = np .int64 )
25- other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 )
26- other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 )
24+ index = Index (range (0 , 20 , 2 ), dtype = np .int64 , name = "lhs" )
25+ other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 , name = "rhs" )
26+ other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 , name = "rhs" )
2727
2828 # not monotonic
2929 res , lidx , ridx = index .join (other , how = "inner" , return_indexers = True )
3030
31- # no guarantee of sortedness, so sort for comparison purposes
32- ind = res .argsort ()
33- res = res .take (ind )
34- lidx = lidx .take (ind )
35- ridx = ridx .take (ind )
36-
37- eres = Index ([2 , 12 ], dtype = np .int64 )
31+ eres = Index ([2 , 12 ], dtype = np .int64 , name = "lhs" )
3832 elidx = np .array ([1 , 6 ], dtype = np .intp )
3933 eridx = np .array ([4 , 1 ], dtype = np .intp )
4034
@@ -46,7 +40,7 @@ def test_join_inner(self):
4640 # monotonic
4741 res , lidx , ridx = index .join (other_mono , how = "inner" , return_indexers = True )
4842
49- res2 = index .intersection (other_mono )
43+ res2 = index .intersection (other_mono ). set_names ([ "lhs" ])
5044 tm .assert_index_equal (res , res2 )
5145
5246 elidx = np .array ([1 , 6 ], dtype = np .intp )
@@ -57,9 +51,9 @@ def test_join_inner(self):
5751 tm .assert_numpy_array_equal (ridx , eridx )
5852
5953 def test_join_left (self ):
60- index = Index (range (0 , 20 , 2 ), dtype = np .int64 )
61- other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 )
62- other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 )
54+ index = Index (range (0 , 20 , 2 ), dtype = np .int64 , name = "lhs" )
55+ other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 , name = "rhs" )
56+ other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 , name = "rhs" )
6357
6458 # not monotonic
6559 res , lidx , ridx = index .join (other , how = "left" , return_indexers = True )
@@ -80,20 +74,20 @@ def test_join_left(self):
8074 tm .assert_numpy_array_equal (ridx , eridx )
8175
8276 # non-unique
83- idx = Index ([1 , 1 , 2 , 5 ])
84- idx2 = Index ([1 , 2 , 5 , 7 , 9 ])
77+ idx = Index ([1 , 1 , 2 , 5 ], name = "rhs" )
78+ idx2 = Index ([1 , 2 , 5 , 7 , 9 ], name = "lhs" )
8579 res , lidx , ridx = idx2 .join (idx , how = "left" , return_indexers = True )
86- eres = Index ([1 , 1 , 2 , 5 , 7 , 9 ]) # 1 is in idx2, so it should be x2
80+ eres = Index ([1 , 1 , 2 , 5 , 7 , 9 ], name = "lhs" ) # 1 is in idx2, so it should be x2
8781 eridx = np .array ([0 , 1 , 2 , 3 , - 1 , - 1 ], dtype = np .intp )
8882 elidx = np .array ([0 , 0 , 1 , 2 , 3 , 4 ], dtype = np .intp )
8983 tm .assert_index_equal (res , eres )
9084 tm .assert_numpy_array_equal (lidx , elidx )
9185 tm .assert_numpy_array_equal (ridx , eridx )
9286
9387 def test_join_right (self ):
94- index = Index (range (0 , 20 , 2 ), dtype = np .int64 )
95- other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 )
96- other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 )
88+ index = Index (range (0 , 20 , 2 ), dtype = np .int64 , name = "lhs" )
89+ other = Index ([7 , 12 , 25 , 1 , 2 , 5 ], dtype = np .int64 , name = "rhs" )
90+ other_mono = Index ([1 , 2 , 5 , 7 , 12 , 25 ], dtype = np .int64 , name = "rhs" )
9791
9892 # not monotonic
9993 res , lidx , ridx = index .join (other , how = "right" , return_indexers = True )
@@ -115,10 +109,10 @@ def test_join_right(self):
115109 assert ridx is None
116110
117111 # non-unique
118- idx = Index ([1 , 1 , 2 , 5 ])
119- idx2 = Index ([1 , 2 , 5 , 7 , 9 ])
112+ idx = Index ([1 , 1 , 2 , 5 ], name = "lhs" )
113+ idx2 = Index ([1 , 2 , 5 , 7 , 9 ], name = "rhs" )
120114 res , lidx , ridx = idx .join (idx2 , how = "right" , return_indexers = True )
121- eres = Index ([1 , 1 , 2 , 5 , 7 , 9 ]) # 1 is in idx2, so it should be x2
115+ eres = Index ([1 , 1 , 2 , 5 , 7 , 9 ], name = "rhs" ) # 1 is in idx2, so it should be x2
122116 elidx = np .array ([0 , 1 , 2 , 3 , - 1 , - 1 ], dtype = np .intp )
123117 eridx = np .array ([0 , 0 , 1 , 2 , 3 , 4 ], dtype = np .intp )
124118 tm .assert_index_equal (res , eres )
0 commit comments