|
13 | 13 | import pandas.algos as _algos
|
14 | 14 | from pandas.compat import lrange
|
15 | 15 | import pandas.core.algorithms as algos
|
16 |
| -import pandas._join as _join |
17 | 16 | import pandas.util.testing as tm
|
18 | 17 | import pandas.hashtable as hashtable
|
19 | 18 | from pandas.compat.numpy import np_array_datetime64_compat
|
@@ -301,46 +300,6 @@ def _test_vector_resize(htable, uniques, dtype, nvals):
|
301 | 300 | _test_vector_resize(tbl(), vect(), dtype, 10)
|
302 | 301 |
|
303 | 302 |
|
304 |
| -class TestIndexer(tm.TestCase): |
305 |
| - _multiprocess_can_split_ = True |
306 |
| - |
307 |
| - def test_outer_join_indexer(self): |
308 |
| - typemap = [('int32', _join.outer_join_indexer_int32), |
309 |
| - ('int64', _join.outer_join_indexer_int64), |
310 |
| - ('float32', _join.outer_join_indexer_float32), |
311 |
| - ('float64', _join.outer_join_indexer_float64), |
312 |
| - ('object', _join.outer_join_indexer_object)] |
313 |
| - |
314 |
| - for dtype, indexer in typemap: |
315 |
| - left = np.arange(3, dtype=dtype) |
316 |
| - right = np.arange(2, 5, dtype=dtype) |
317 |
| - empty = np.array([], dtype=dtype) |
318 |
| - |
319 |
| - result, lindexer, rindexer = indexer(left, right) |
320 |
| - tm.assertIsInstance(result, np.ndarray) |
321 |
| - tm.assertIsInstance(lindexer, np.ndarray) |
322 |
| - tm.assertIsInstance(rindexer, np.ndarray) |
323 |
| - tm.assert_numpy_array_equal(result, np.arange(5, dtype=dtype)) |
324 |
| - exp = np.array([0, 1, 2, -1, -1], dtype=np.int64) |
325 |
| - tm.assert_numpy_array_equal(lindexer, exp) |
326 |
| - exp = np.array([-1, -1, 0, 1, 2], dtype=np.int64) |
327 |
| - tm.assert_numpy_array_equal(rindexer, exp) |
328 |
| - |
329 |
| - result, lindexer, rindexer = indexer(empty, right) |
330 |
| - tm.assert_numpy_array_equal(result, right) |
331 |
| - exp = np.array([-1, -1, -1], dtype=np.int64) |
332 |
| - tm.assert_numpy_array_equal(lindexer, exp) |
333 |
| - exp = np.array([0, 1, 2], dtype=np.int64) |
334 |
| - tm.assert_numpy_array_equal(rindexer, exp) |
335 |
| - |
336 |
| - result, lindexer, rindexer = indexer(left, empty) |
337 |
| - tm.assert_numpy_array_equal(result, left) |
338 |
| - exp = np.array([0, 1, 2], dtype=np.int64) |
339 |
| - tm.assert_numpy_array_equal(lindexer, exp) |
340 |
| - exp = np.array([-1, -1, -1], dtype=np.int64) |
341 |
| - tm.assert_numpy_array_equal(rindexer, exp) |
342 |
| - |
343 |
| - |
344 | 303 | class TestUnique(tm.TestCase):
|
345 | 304 | _multiprocess_can_split_ = True
|
346 | 305 |
|
@@ -1068,153 +1027,6 @@ def test_pad(self):
|
1068 | 1027 | self.assert_numpy_array_equal(filler, expect_filler)
|
1069 | 1028 |
|
1070 | 1029 |
|
1071 |
| -def test_left_join_indexer_unique(): |
1072 |
| - a = np.array([1, 2, 3, 4, 5], dtype=np.int64) |
1073 |
| - b = np.array([2, 2, 3, 4, 4], dtype=np.int64) |
1074 |
| - |
1075 |
| - result = _join.left_join_indexer_unique_int64(b, a) |
1076 |
| - expected = np.array([1, 1, 2, 3, 3], dtype=np.int64) |
1077 |
| - assert (np.array_equal(result, expected)) |
1078 |
| - |
1079 |
| - |
1080 |
| -def test_left_outer_join_bug(): |
1081 |
| - left = np.array([0, 1, 0, 1, 1, 2, 3, 1, 0, 2, 1, 2, 0, 1, 1, 2, 3, 2, 3, |
1082 |
| - 2, 1, 1, 3, 0, 3, 2, 3, 0, 0, 2, 3, 2, 0, 3, 1, 3, 0, 1, |
1083 |
| - 3, 0, 0, 1, 0, 3, 1, 0, 1, 0, 1, 1, 0, 2, 2, 2, 2, 2, 0, |
1084 |
| - 3, 1, 2, 0, 0, 3, 1, 3, 2, 2, 0, 1, 3, 0, 2, 3, 2, 3, 3, |
1085 |
| - 2, 3, 3, 1, 3, 2, 0, 0, 3, 1, 1, 1, 0, 2, 3, 3, 1, 2, 0, |
1086 |
| - 3, 1, 2, 0, 2], dtype=np.int64) |
1087 |
| - |
1088 |
| - right = np.array([3, 1], dtype=np.int64) |
1089 |
| - max_groups = 4 |
1090 |
| - |
1091 |
| - lidx, ridx = _join.left_outer_join(left, right, max_groups, sort=False) |
1092 |
| - |
1093 |
| - exp_lidx = np.arange(len(left)) |
1094 |
| - exp_ridx = -np.ones(len(left)) |
1095 |
| - exp_ridx[left == 1] = 1 |
1096 |
| - exp_ridx[left == 3] = 0 |
1097 |
| - |
1098 |
| - assert (np.array_equal(lidx, exp_lidx)) |
1099 |
| - assert (np.array_equal(ridx, exp_ridx)) |
1100 |
| - |
1101 |
| - |
1102 |
| -def test_inner_join_indexer(): |
1103 |
| - a = np.array([1, 2, 3, 4, 5], dtype=np.int64) |
1104 |
| - b = np.array([0, 3, 5, 7, 9], dtype=np.int64) |
1105 |
| - |
1106 |
| - index, ares, bres = _join.inner_join_indexer_int64(a, b) |
1107 |
| - |
1108 |
| - index_exp = np.array([3, 5], dtype=np.int64) |
1109 |
| - assert_almost_equal(index, index_exp) |
1110 |
| - |
1111 |
| - aexp = np.array([2, 4], dtype=np.int64) |
1112 |
| - bexp = np.array([1, 2], dtype=np.int64) |
1113 |
| - assert_almost_equal(ares, aexp) |
1114 |
| - assert_almost_equal(bres, bexp) |
1115 |
| - |
1116 |
| - a = np.array([5], dtype=np.int64) |
1117 |
| - b = np.array([5], dtype=np.int64) |
1118 |
| - |
1119 |
| - index, ares, bres = _join.inner_join_indexer_int64(a, b) |
1120 |
| - tm.assert_numpy_array_equal(index, np.array([5], dtype=np.int64)) |
1121 |
| - tm.assert_numpy_array_equal(ares, np.array([0], dtype=np.int64)) |
1122 |
| - tm.assert_numpy_array_equal(bres, np.array([0], dtype=np.int64)) |
1123 |
| - |
1124 |
| - |
1125 |
| -def test_outer_join_indexer(): |
1126 |
| - a = np.array([1, 2, 3, 4, 5], dtype=np.int64) |
1127 |
| - b = np.array([0, 3, 5, 7, 9], dtype=np.int64) |
1128 |
| - |
1129 |
| - index, ares, bres = _join.outer_join_indexer_int64(a, b) |
1130 |
| - |
1131 |
| - index_exp = np.array([0, 1, 2, 3, 4, 5, 7, 9], dtype=np.int64) |
1132 |
| - assert_almost_equal(index, index_exp) |
1133 |
| - |
1134 |
| - aexp = np.array([-1, 0, 1, 2, 3, 4, -1, -1], dtype=np.int64) |
1135 |
| - bexp = np.array([0, -1, -1, 1, -1, 2, 3, 4], dtype=np.int64) |
1136 |
| - assert_almost_equal(ares, aexp) |
1137 |
| - assert_almost_equal(bres, bexp) |
1138 |
| - |
1139 |
| - a = np.array([5], dtype=np.int64) |
1140 |
| - b = np.array([5], dtype=np.int64) |
1141 |
| - |
1142 |
| - index, ares, bres = _join.outer_join_indexer_int64(a, b) |
1143 |
| - tm.assert_numpy_array_equal(index, np.array([5], dtype=np.int64)) |
1144 |
| - tm.assert_numpy_array_equal(ares, np.array([0], dtype=np.int64)) |
1145 |
| - tm.assert_numpy_array_equal(bres, np.array([0], dtype=np.int64)) |
1146 |
| - |
1147 |
| - |
1148 |
| -def test_left_join_indexer(): |
1149 |
| - a = np.array([1, 2, 3, 4, 5], dtype=np.int64) |
1150 |
| - b = np.array([0, 3, 5, 7, 9], dtype=np.int64) |
1151 |
| - |
1152 |
| - index, ares, bres = _join.left_join_indexer_int64(a, b) |
1153 |
| - |
1154 |
| - assert_almost_equal(index, a) |
1155 |
| - |
1156 |
| - aexp = np.array([0, 1, 2, 3, 4], dtype=np.int64) |
1157 |
| - bexp = np.array([-1, -1, 1, -1, 2], dtype=np.int64) |
1158 |
| - assert_almost_equal(ares, aexp) |
1159 |
| - assert_almost_equal(bres, bexp) |
1160 |
| - |
1161 |
| - a = np.array([5], dtype=np.int64) |
1162 |
| - b = np.array([5], dtype=np.int64) |
1163 |
| - |
1164 |
| - index, ares, bres = _join.left_join_indexer_int64(a, b) |
1165 |
| - tm.assert_numpy_array_equal(index, np.array([5], dtype=np.int64)) |
1166 |
| - tm.assert_numpy_array_equal(ares, np.array([0], dtype=np.int64)) |
1167 |
| - tm.assert_numpy_array_equal(bres, np.array([0], dtype=np.int64)) |
1168 |
| - |
1169 |
| - |
1170 |
| -def test_left_join_indexer2(): |
1171 |
| - idx = Index([1, 1, 2, 5]) |
1172 |
| - idx2 = Index([1, 2, 5, 7, 9]) |
1173 |
| - |
1174 |
| - res, lidx, ridx = _join.left_join_indexer_int64(idx2.values, idx.values) |
1175 |
| - |
1176 |
| - exp_res = np.array([1, 1, 2, 5, 7, 9], dtype=np.int64) |
1177 |
| - assert_almost_equal(res, exp_res) |
1178 |
| - |
1179 |
| - exp_lidx = np.array([0, 0, 1, 2, 3, 4], dtype=np.int64) |
1180 |
| - assert_almost_equal(lidx, exp_lidx) |
1181 |
| - |
1182 |
| - exp_ridx = np.array([0, 1, 2, 3, -1, -1], dtype=np.int64) |
1183 |
| - assert_almost_equal(ridx, exp_ridx) |
1184 |
| - |
1185 |
| - |
1186 |
| -def test_outer_join_indexer2(): |
1187 |
| - idx = Index([1, 1, 2, 5]) |
1188 |
| - idx2 = Index([1, 2, 5, 7, 9]) |
1189 |
| - |
1190 |
| - res, lidx, ridx = _join.outer_join_indexer_int64(idx2.values, idx.values) |
1191 |
| - |
1192 |
| - exp_res = np.array([1, 1, 2, 5, 7, 9], dtype=np.int64) |
1193 |
| - assert_almost_equal(res, exp_res) |
1194 |
| - |
1195 |
| - exp_lidx = np.array([0, 0, 1, 2, 3, 4], dtype=np.int64) |
1196 |
| - assert_almost_equal(lidx, exp_lidx) |
1197 |
| - |
1198 |
| - exp_ridx = np.array([0, 1, 2, 3, -1, -1], dtype=np.int64) |
1199 |
| - assert_almost_equal(ridx, exp_ridx) |
1200 |
| - |
1201 |
| - |
1202 |
| -def test_inner_join_indexer2(): |
1203 |
| - idx = Index([1, 1, 2, 5]) |
1204 |
| - idx2 = Index([1, 2, 5, 7, 9]) |
1205 |
| - |
1206 |
| - res, lidx, ridx = _join.inner_join_indexer_int64(idx2.values, idx.values) |
1207 |
| - |
1208 |
| - exp_res = np.array([1, 1, 2, 5], dtype=np.int64) |
1209 |
| - assert_almost_equal(res, exp_res) |
1210 |
| - |
1211 |
| - exp_lidx = np.array([0, 0, 1, 2], dtype=np.int64) |
1212 |
| - assert_almost_equal(lidx, exp_lidx) |
1213 |
| - |
1214 |
| - exp_ridx = np.array([0, 1, 2, 3], dtype=np.int64) |
1215 |
| - assert_almost_equal(ridx, exp_ridx) |
1216 |
| - |
1217 |
| - |
1218 | 1030 | def test_is_lexsorted():
|
1219 | 1031 | failure = [
|
1220 | 1032 | np.array([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
|
0 commit comments