diff --git a/abl/evaluation/semantics_metric.py b/abl/evaluation/semantics_metric.py index 271ca1c..14c4f46 100644 --- a/abl/evaluation/semantics_metric.py +++ b/abl/evaluation/semantics_metric.py @@ -10,10 +10,10 @@ 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_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_pseudo_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) diff --git a/abl/utils/utils.py b/abl/utils/utils.py index 0b5dff4..6e3bb4f 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.