def format_data(self, result): if self.text_format == 'full': text = (f"{result.test_short_name} " if self.show_test_name else "") return ("{}p = {}{}".format('{}', self.pvalue_format_string, '{}').format( text, result.pvalue, result.significance_suffix)) elif self.text_format == 'star': was_list = False if not isinstance(result, list): result = [result] annotations = [ get_corrected_star(star, res, self._correction_format) for star, res in pval_annotation_text(result, self.pvalue_thresholds) ] if was_list: return annotations return annotations[0] elif self.text_format == 'simple': return simple_text(result, self.simple_format_string, self.pvalue_thresholds, self.show_test_name)
def format_data(self, result): if self.text_format == 'full': return ("{} p = {}{}".format('{}', self.pvalue_format_string, '{}').format( result.test_short_name, result.pvalue, result.significance_suffix)) elif self.text_format == 'star': return pval_annotation_text(result, self.pvalue_thresholds) elif self.text_format == 'simple': return simple_text(result, self.simple_format_string, self.pvalue_thresholds)
def test_format_simple_non_significant(self): self.assertEqual(simple_text(self.result, "{:.2f}", [(0.2, 0.2)]), "This p = 0.30")
def test_format_simple_setting_multiple_thresholds(self): self.assertEqual( simple_text(self.result, "{:.2f}", [(0.1, 0.1), (0.5, 0.5)]), "This p ≤ 0.5")
def test_format_simple_without_test_name(self): self.assertEqual( simple_text(self.result, "{:.2f}", [(0.5, 0.5)], False), "p ≤ 0.5")