Example #1
0
 def collect(self, table, cells):
     """
     Add cells for the specified diff columns and dynamically compute their values
     from the respective data columns. If one of the values is None, set the difference
     to the string '-'. Calculate the summary functions over all values were both
     columns have a value. Also add an empty header for a dummy column after every diff
     column.
     """
     for col_names, diff_col_header, diff_col_name in self.compared_configs:
         non_none_values = []
         cells[table.header_row][diff_col_name] = diff_col_header
         for row_name in table.row_names:
             values = [
                 table[row_name].get(col_name, None)
                 for col_name in col_names
             ]
             try:
                 diff = float(values[1]) - float(values[0])
             except (ValueError, TypeError):
                 diff = None
             if diff is not None:
                 non_none_values.append(diff)
                 cells[row_name][diff_col_name] = diff
         for func in self.summary_functions:
             func_name = reports.function_name(func)
             cells[func_name][table.header_column] = func_name.capitalize()
             cells[func_name][diff_col_name] = func(non_none_values)
     return cells
Example #2
0
 def collect(self, table, cells):
     """
     Add cells for the specified diff columns and dynamically compute their values
     from the respective data columns. If one of the values is None, set the difference
     to the string '-'. Calculate the summary functions over all values were both
     columns have a value. Also add an empty header for a dummy column after every diff
     column.
     """
     for col_names, diff_col_header, diff_col_name in self.compared_configs:
         non_none_values = []
         cells[table.header_row][diff_col_name] = diff_col_header
         for row_name in table.row_names:
             values = [table[row_name].get(col_name, None) for col_name in col_names]
             try:
                 diff = float(values[1]) - float(values[0])
             except (ValueError, TypeError):
                 diff = None
             if diff is not None:
                 non_none_values.append(diff)
                 cells[row_name][diff_col_name] = diff
         for func in self.summary_functions:
             func_name = reports.function_name(func)
             cells[func_name][table.header_column] = func_name.capitalize()
             cells[func_name][diff_col_name] = func(non_none_values)
     return cells
Example #3
0
 def modify_printable_row_order(self, table, row_order):
     """
     Append lines for all summary functions that are not already used to the row order.
     """
     for func in self.summary_functions:
         func_name = reports.function_name(func)
         if func_name not in row_order:
             row_order.append(func_name)
     return row_order
Example #4
0
 def modify_printable_row_order(self, table, row_order):
     """
     Append lines for all summary functions that are not already used to the row order.
     """
     for func in self.summary_functions:
         func_name = reports.function_name(func)
         if func_name not in row_order:
             row_order.append(func_name)
     return row_order
Example #5
0
 def _get_aggregation_function(self, attribute):
     """Decide on a list of group functions for this attribute."""
     func = attribute.function
     return (reports.function_name(func), func)
Example #6
0
 def _get_function_name(function):
     return reports.function_name(function) + " of diffs"
Example #7
0
 def _get_group_functions(self, attribute):
     """Decide on a list of group functions for this attribute."""
     return [(reports.function_name(f), f) for f in attribute.functions]
Example #8
0
 def _get_group_functions(self, attribute):
     """Decide on a list of group functions for this attribute."""
     return [(reports.function_name(f), f) for f in attribute.functions]