def add_confidence(self, result, value, confidence_reached):
     if confidence_reached:
         detail = self.display_names["confidence_reached"]
     else:
         detail = self.display_names["confidence_not_reached"]
     result.add_element(
         SingleElement(self.display_names["confidence"],
                       "{}% ({})".format(value, detail)))
 def add_test_suite(self, result, test_suite, descriptions):
     # arrange attributes so the ones used in the descriptions goes first
     sorted_columns = list(descriptions[0].keys())
     sorted_columns.insert(0, PREDICTED_OUTCOME)
     for column in test_suite.columns:
         if column not in sorted_columns:
             sorted_columns.append(column)
     if PREDICTED_PROBABILITY in sorted_columns:
         sorted_columns.remove(PREDICTED_PROBABILITY)
     if OUTCOME in sorted_columns:
         sorted_columns.remove(OUTCOME)
     testing_suite = test_suite[sorted_columns]
     testing_suite = testing_suite.rename(
         columns={
             PREDICTED_OUTCOME: self.display_names["predicted_outcome"]
         })
     column_names = list(testing_suite.columns)
     data = testing_suite.values.tolist()
     result.add_element(
         TableElement(self.display_names["test_suite"], column_names, data))
     result.add_element(
         SingleElement(self.display_names["test_suite_total_cases"],
                       len(data)))
 def add_maximum_acceptable_difference(self, result, value):
     result.add_element(
         SingleElement(self.display_names["maximum_acceptable_difference"],
                       value))
 def add_percentage(self, result, proportion, error):
     result.add_element(
         SingleElement(
             self.display_names["percentage"],
             "({} ± {})%".format(round(proportion * 100, 2), error)))
 def add_minimum_samples_amount(self, result, value):
     result.add_element(
         SingleElement(self.display_names["minimum_samples_amount"], value))
 def add_decimals(self, result, value):
     result.add_element(SingleElement(self.display_names["decimals"],
                                      value))
        if len(failing_cases) > 0:
            column_names = [
                "{} 1".format(self.display_names["individual"]),
                "{} 2".format(self.display_names["individual"]),
                self.display_names["individuals_distance"],
                self.display_names["outcomes_distance"]
            ]
            data = [[
                case.individual1.name, case.individual2.name,
                case.individuals_distance, case.outcomes_distance
            ] for case in failing_cases]
            result.add_element(
                TableElement(self.display_names["failing_cases_table"],
                             column_names, data))
        result.add_element(
            SingleElement(self.display_names["failing_cases"],
                          len(failing_cases)))

    def add_probabilities_table(self, result, template, column_satisfies,
                                descriptions, probabilities_table):
        row_descriptions = list()
        for description in descriptions:
            formatted_description = format_description(description)
            row_descriptions.append(template.format(formatted_description))
        column_names = list(probabilities_table[0].keys())
        column_names.insert(0, "s")
        data = [
            list(round(value, 3) for value in dict_probabilities.values())
            for dict_probabilities in probabilities_table
        ]
        for i, row in enumerate(data):
            row.insert(0, row_descriptions[i])