def test_build_id_to_index_map_2(self): table = [['a1', 'hello'], ['a1', 'world']] key = 'ID' dataframe = pd.DataFrame(table) dataframe.columns = ['ID', 'title'] em.set_key(dataframe, key) db._build_id_to_index_map(dataframe, key)
def test_build_id_to_index_map_2(self): table = [['a1', 'hello'], ['a1', 'world']] key = 'ID' dataframe = pd.DataFrame(table) dataframe.columns = ['ID', 'title'] em.set_key(dataframe, key) db._build_id_to_index_map(dataframe, key)
def test_index_candidate_set_3(self): A = read_csv_metadata(path_a, key='ID') B = read_csv_metadata(path_b, key='ID') l_key = cm.get_key(A) r_key = cm.get_key(B) C = read_csv_metadata(path_c, ltable=A, rtable=B, fk_ltable='ltable_' + l_key, fk_rtable='rtable_' + r_key, key = '_id') C.ix[0, 'rtable_ID'] = 'bbbb' lrecord_id_to_index_map = db._build_id_to_index_map(A, l_key) rrecord_id_to_index_map = db._build_id_to_index_map(B, r_key) db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False)
def test_index_candidate_set_3(self): A = read_csv_metadata(path_a, key='ID') B = read_csv_metadata(path_b, key='ID') l_key = cm.get_key(A) r_key = cm.get_key(B) C = read_csv_metadata(path_c, ltable=A, rtable=B, fk_ltable='ltable_' + l_key, fk_rtable='rtable_' + r_key, key = '_id') C.loc[0, 'rtable_ID'] = 'bbbb' lrecord_id_to_index_map = db._build_id_to_index_map(A, l_key) rrecord_id_to_index_map = db._build_id_to_index_map(B, r_key) db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False)
def test_index_candidate_set_6(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C = pd.DataFrame() lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') new_C = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(new_C, {})
def test_index_candidate_set_6(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C = pd.DataFrame() lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') new_C = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(new_C, {})
def test_index_candidate_set_1(self): A = read_csv_metadata(path_a, key='ID') B = read_csv_metadata(path_b, key='ID') l_key = cm.get_key(A) r_key = cm.get_key(B) C = read_csv_metadata(path_c, ltable=A, rtable=B, fk_ltable='ltable_' + l_key, fk_rtable='rtable_' + r_key, key = '_id') lrecord_id_to_index_map = db._build_id_to_index_map(A, l_key) rrecord_id_to_index_map = db._build_id_to_index_map(B, r_key) expected_cand_set = {0: set([0, 1, 5]), 1: set([2, 3, 4]), 2: set([0, 1, 5]), 3: set([2, 3, 4]), 4: set([2, 3, 4])} actual_cand_set = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(expected_cand_set, actual_cand_set)
def test_index_candidate_set_1(self): A = read_csv_metadata(path_a, key='ID') B = read_csv_metadata(path_b, key='ID') l_key = cm.get_key(A) r_key = cm.get_key(B) C = read_csv_metadata(path_c, ltable=A, rtable=B, fk_ltable='ltable_' + l_key, fk_rtable='rtable_' + r_key, key = '_id') lrecord_id_to_index_map = db._build_id_to_index_map(A, l_key) rrecord_id_to_index_map = db._build_id_to_index_map(B, r_key) expected_cand_set = {0: set([0, 1, 5]), 1: set([2, 3, 4]), 2: set([0, 1, 5]), 3: set([2, 3, 4]), 4: set([2, 3, 4])} actual_cand_set = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(expected_cand_set, actual_cand_set)
def test_index_candidate_set_5(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C_list = [[0, 1, 'B001'], [1, 2, 'B002']] C = pd.DataFrame(C_list) C.columns = ['_id', 'ltable_ID', 'rtable_ID'] cm.set_candset_properties(C, '_id', 'ltable_ID', 'rtable_ID', A, B) lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False)
def test_index_candidate_set_5(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C_list = [[0, 1, 'B001'], [1, 2, 'B002']] C = pd.DataFrame(C_list) C.columns = ['_id', 'ltable_ID', 'rtable_ID'] cm.set_candset_properties(C, '_id', 'ltable_ID', 'rtable_ID', A, B) lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False)
def test_index_candidate_set_4(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C_list = [[0, 1, 'B003'], [1, 2, 'B002']] C = pd.DataFrame(C_list) C.columns = ['_id', 'ltable_ID', 'rtable_ID'] cm.set_candset_properties(C, '_id', 'ltable_ID', 'rtable_ID', A, B) lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') expected_cand_set = {0: set([1]), 1: set([0])} actual_cand_set = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(expected_cand_set, actual_cand_set)
def test_index_candidate_set_4(self): A_list = [[1, 'asdf', 'fdas'], [2, 'fdsa', 'asdf']] B_list = [['B002', 'qqqq', 'wwww'], ['B003', 'rrrr', 'fdsa']] A = pd.DataFrame(A_list) A.columns = ['ID', 'f1', 'f2'] em.set_key(A, 'ID') B = pd.DataFrame(B_list) B.columns = ['ID', 'f1', 'f2'] em.set_key(B, 'ID') C_list = [[0, 1, 'B003'], [1, 2, 'B002']] C = pd.DataFrame(C_list) C.columns = ['_id', 'ltable_ID', 'rtable_ID'] cm.set_candset_properties(C, '_id', 'ltable_ID', 'rtable_ID', A, B) lrecord_id_to_index_map = db._build_id_to_index_map(A, 'ID') rrecord_id_to_index_map = db._build_id_to_index_map(B, 'ID') expected_cand_set = {0: set([1]), 1: set([0])} actual_cand_set = db._index_candidate_set(C, lrecord_id_to_index_map, rrecord_id_to_index_map, False) self.assertEqual(expected_cand_set, actual_cand_set)
def test_build_id_to_index_map_1(self): A = read_csv_metadata(path_a, key='ID') key = em.get_key(A) actual_rec_id_to_idx = db._build_id_to_index_map(A, key) expected_rec_id_to_idx = {'a1': 0, 'a3': 2, 'a2': 1, 'a5': 4, 'a4': 3} self.assertEqual(actual_rec_id_to_idx, expected_rec_id_to_idx)
def test_build_id_to_index_map_1(self): A = read_csv_metadata(path_a, key='ID') key = em.get_key(A) actual_rec_id_to_idx = db._build_id_to_index_map(A, key) expected_rec_id_to_idx = {'a1': 0, 'a3': 2, 'a2': 1, 'a5': 4, 'a4': 3} self.assertEqual(actual_rec_id_to_idx, expected_rec_id_to_idx)