55 RangeIndex ,
66)
77import pandas ._testing as tm
8- from pandas .core .indexes .api import Int64Index
98
109
1110class TestJoin :
1211 def test_join_outer (self ):
13- # join with Int64Index
12+ # join with Index[int64]
1413 index = RangeIndex (start = 0 , stop = 20 , step = 2 )
15- other = Int64Index (np .arange (25 , 14 , - 1 ))
14+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
1615
1716 res , lidx , ridx = index .join (other , how = "outer" , return_indexers = True )
1817 noidx_res = index .join (other , how = "outer" )
1918 tm .assert_index_equal (res , noidx_res )
2019
21- eres = Int64Index (
20+ eres = Index (
2221 [0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 ]
2322 )
2423 elidx = np .array (
@@ -30,9 +29,9 @@ def test_join_outer(self):
3029 dtype = np .intp ,
3130 )
3231
33- assert isinstance (res , Int64Index )
32+ assert isinstance (res , Index ) and res . dtype == np . int64
3433 assert not isinstance (res , RangeIndex )
35- tm .assert_index_equal (res , eres )
34+ tm .assert_index_equal (res , eres , exact = True )
3635 tm .assert_numpy_array_equal (lidx , elidx )
3736 tm .assert_numpy_array_equal (ridx , eridx )
3837
@@ -43,7 +42,7 @@ def test_join_outer(self):
4342 noidx_res = index .join (other , how = "outer" )
4443 tm .assert_index_equal (res , noidx_res )
4544
46- assert isinstance (res , Int64Index )
45+ assert isinstance (res , Index ) and res . dtype == np . int64
4746 assert not isinstance (res , RangeIndex )
4847 tm .assert_index_equal (res , eres )
4948 tm .assert_numpy_array_equal (lidx , elidx )
@@ -52,7 +51,7 @@ def test_join_outer(self):
5251 def test_join_inner (self ):
5352 # Join with non-RangeIndex
5453 index = RangeIndex (start = 0 , stop = 20 , step = 2 )
55- other = Int64Index (np .arange (25 , 14 , - 1 ))
54+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
5655
5756 res , lidx , ridx = index .join (other , how = "inner" , return_indexers = True )
5857
@@ -62,7 +61,7 @@ def test_join_inner(self):
6261 lidx = lidx .take (ind )
6362 ridx = ridx .take (ind )
6463
65- eres = Int64Index ([16 , 18 ])
64+ eres = Index ([16 , 18 ])
6665 elidx = np .array ([8 , 9 ], dtype = np .intp )
6766 eridx = np .array ([9 , 7 ], dtype = np .intp )
6867
@@ -82,9 +81,9 @@ def test_join_inner(self):
8281 tm .assert_numpy_array_equal (ridx , eridx )
8382
8483 def test_join_left (self ):
85- # Join with Int64Index
84+ # Join with Index[int64]
8685 index = RangeIndex (start = 0 , stop = 20 , step = 2 )
87- other = Int64Index (np .arange (25 , 14 , - 1 ))
86+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
8887
8988 res , lidx , ridx = index .join (other , how = "left" , return_indexers = True )
9089 eres = index
@@ -96,7 +95,7 @@ def test_join_left(self):
9695 tm .assert_numpy_array_equal (ridx , eridx )
9796
9897 # Join withRangeIndex
99- other = Int64Index (np .arange (25 , 14 , - 1 ))
98+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
10099
101100 res , lidx , ridx = index .join (other , how = "left" , return_indexers = True )
102101
@@ -106,15 +105,15 @@ def test_join_left(self):
106105 tm .assert_numpy_array_equal (ridx , eridx )
107106
108107 def test_join_right (self ):
109- # Join with Int64Index
108+ # Join with Index[int64]
110109 index = RangeIndex (start = 0 , stop = 20 , step = 2 )
111- other = Int64Index (np .arange (25 , 14 , - 1 ))
110+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
112111
113112 res , lidx , ridx = index .join (other , how = "right" , return_indexers = True )
114113 eres = other
115114 elidx = np .array ([- 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 9 , - 1 , 8 , - 1 ], dtype = np .intp )
116115
117- assert isinstance (other , Int64Index )
116+ assert isinstance (other , Index ) and other . dtype == np . int64
118117 tm .assert_index_equal (res , eres )
119118 tm .assert_numpy_array_equal (lidx , elidx )
120119 assert ridx is None
@@ -164,7 +163,7 @@ def test_join_non_unique(self):
164163
165164 res , lidx , ridx = index .join (other , return_indexers = True )
166165
167- eres = Int64Index ([0 , 2 , 4 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 ])
166+ eres = Index ([0 , 2 , 4 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 ])
168167 elidx = np .array ([0 , 1 , 2 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ], dtype = np .intp )
169168 eridx = np .array ([- 1 , - 1 , 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 ], dtype = np .intp )
170169
0 commit comments