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
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
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
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)
def _get_function_name(function): return reports.function_name(function) + " of diffs"
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]