From c7ac3ba0b8859d9e4976e83bf62ebd05a95d6743 Mon Sep 17 00:00:00 2001 From: troyyyyy Date: Thu, 16 Nov 2023 09:17:39 +0800 Subject: [PATCH 1/3] [FIX] fix typo --- abl/evaluation/semantics_metric.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abl/evaluation/semantics_metric.py b/abl/evaluation/semantics_metric.py index 271ca1c..0e82ee9 100644 --- a/abl/evaluation/semantics_metric.py +++ b/abl/evaluation/semantics_metric.py @@ -12,8 +12,8 @@ class SemanticsMetric(BaseMetric): def process(self, data_samples: Sequence[dict]) -> None: pred_psedudo_label_list = data_samples.pred_pseudo_label y_list = data_samples.Y - for pred_psedudo_label, y in zip(pred_psedudo_label_list, y_list): - if self.kb._check_equal(self.kb.logic_forward(pred_psedudo_label), y): + for pred_pseudo_label, y in zip(pred_psedudo_label_list, y_list): + if self.kb._check_equal(self.kb.logic_forward(pred_pseudo_label), y): self.results.append(1) else: self.results.append(0) From dcb24dec55c87ad9d2fc9c662230fb7a22daee3b Mon Sep 17 00:00:00 2001 From: troyyyyy Date: Thu, 16 Nov 2023 09:18:08 +0800 Subject: [PATCH 2/3] [FIX] fix typo --- abl/evaluation/semantics_metric.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abl/evaluation/semantics_metric.py b/abl/evaluation/semantics_metric.py index 0e82ee9..14c4f46 100644 --- a/abl/evaluation/semantics_metric.py +++ b/abl/evaluation/semantics_metric.py @@ -10,9 +10,9 @@ class SemanticsMetric(BaseMetric): self.kb = kb def process(self, data_samples: Sequence[dict]) -> None: - pred_psedudo_label_list = data_samples.pred_pseudo_label + pred_pseudo_label_list = data_samples.pred_pseudo_label y_list = data_samples.Y - for pred_pseudo_label, y in zip(pred_psedudo_label_list, y_list): + for pred_pseudo_label, y in zip(pred_pseudo_label_list, y_list): if self.kb._check_equal(self.kb.logic_forward(pred_pseudo_label), y): self.results.append(1) else: From fa0d2a7dd0a5e1864cd36cca50d6e0b43df797a3 Mon Sep 17 00:00:00 2001 From: troyyyyy Date: Thu, 16 Nov 2023 09:22:19 +0800 Subject: [PATCH 3/3] [FIX] remove obsolete function in utils --- abl/utils/utils.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/abl/utils/utils.py b/abl/utils/utils.py index 1480045..1a6f615 100644 --- a/abl/utils/utils.py +++ b/abl/utils/utils.py @@ -144,34 +144,6 @@ def block_sample(X, Z, Y, sample_num, seg_idx): return (data[start_idx:end_idx] for data in (X, Z, Y)) -def check_equal(a, b, max_err=0): - """ - Check whether two numbers a and b are equal within a maximum allowable error. - - Parameters - ---------- - a, b : int or float - The numbers to compare. - max_err : int or float, optional - The maximum allowable absolute difference between a and b for them to be considered equal. - Default is 0, meaning the numbers must be exactly equal. - - Returns - ------- - bool - True if a and b are equal within the allowable error, False otherwise. - - Raises - ------ - TypeError - If a or b are not of type int or float. - """ - if not (isinstance(a, (int, float)) and isinstance(b, (int, float))): - raise TypeError("Input values must be int or float.") - - return abs(a - b) <= max_err - - def to_hashable(x): """ Convert a nested list to a nested tuple so it is hashable.