Exemple #1
0
def emp_de_two(tables, cols, col_funcs):
    '''
    Reduce a list of tables to a single table that have
    the required cols in the list
    :param tables: a list of dicts with col_name (key) and entries (value)
    :param cols: a list of col_names
    :param col_funcs: functions to executes on column entries, a dict
    :return: a single dict with col_name (key) and entries (value)
    '''
    # reduce each table of the list
    reduced = [man.reduce_tb(tb, cols) for tb in tables]
    '''
    def check_tb(table):
        return {col_name: perf_func(col_name, entries)
                for col_name, entries in table.items()}

    def perf_func(col_name, entries):
        if col_funcs.get(col_name, None) is None:
            # if there's no need to perform col func, return entries as it is
            return entries
        # Get the name of the column function
        func_name = col_funcs[col_name]
        # perform col functions on column entries
        return [eva.FUNC[func_name](entries)]

    reduced = [check_tb(tb) for tb in reduced]
    '''
    # Join all the tables together into one
    joined = man.combine(reduced)
    return joined
Exemple #2
0
 def test_combine_two_tables(self):
     combined_col1 = [i for i in range(0, 50) for __ in range(0, 50)]
     combined_col2 = [i for i in range(100, 150) for __ in range(0, 50)]
     test = man.combine((self.tb1, self.tb2))
     # Check combined_col1
     self.assertEqual(combined_col1, list(test['col1']))
     # Check combined_col2
     self.assertEqual(combined_col2, list(test['col2']))
 def test_combine_two_tables(self):
     combined_col1 = [i for i in range(0, 50) for __ in range(0, 50)]
     combined_col2 = [i for i in range(100, 150) for __ in range(0, 50)]
     test = man.combine((self.tb1, self.tb2))
     # Check combined_col1
     self.assertEqual(combined_col1, list(test['col1']))
     # Check combined_col2
     self.assertEqual(combined_col2, list(test['col2']))
Exemple #4
0
 def test_combine_three_tables(self):
     combined_col3 = [i for i in range(0, 3) for __ in range(0, 30)]
     combined_col4 = [i for i in range(10, 13) for __ in range(0, 30)]
     combined_col5 = [i for i in range(0, 5) for __ in range(0, 18)]
     combined_col6 = [i for i in range(0, 6) for __ in range(0, 15)]
     test = man.combine((self.tb3, self.tb4, self.tb5))
     # Check combined_col3
     self.assertEqual(combined_col3, list(test['col3']))
     # Check combined_col4
     self.assertEqual(combined_col4, list(test['col4']))
     # Check combined_col5
     self.assertEqual(combined_col5, list(test['col5']))
     # Check combined_col6
     self.assertEqual(combined_col6, list(test['col6']))
 def test_combine_three_tables(self):
     combined_col3 = [i for i in range(0, 3) for __ in range(0, 30)]
     combined_col4 = [i for i in range(10, 13) for __ in range(0, 30)]
     combined_col5 = [i for i in range(0, 5) for __ in range(0, 18)]
     combined_col6 = [i for i in range(0, 6) for __ in range(0, 15)]
     test = man.combine((self.tb3, self.tb4, self.tb5))
     # Check combined_col3
     self.assertEqual(combined_col3, list(test['col3']))
     # Check combined_col4
     self.assertEqual(combined_col4, list(test['col4']))
     # Check combined_col5
     self.assertEqual(combined_col5, list(test['col5']))
     # Check combined_col6
     self.assertEqual(combined_col6, list(test['col6']))
Exemple #6
0
 def test_combine_one_table(self):
     test = man.combine([self.tb1])
     self.assertEqual(self.col1, list(test['col1']))
 def test_combine_one_table(self):
     test = man.combine([self.tb1])
     self.assertEqual(self.col1, list(test['col1']))