Skip to content

Commit

Permalink
Fix logic for MultiModal metric and verbose it
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianDeconinck committed Dec 11, 2024
1 parent 8daf5bd commit 9faa405
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ndsl/testing/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,19 @@ def _compute_all_metrics(
self.ulp_distance_metric = self.ulp_distance <= self.ulp_threshold.value

# Combine all distances into sucess or failure
# Success = no NANs & ( abs or rel or ulp )
naninf_success = not np.logical_and(
# Success =
# - no unexpected NANs (e.g. NaN in the ref MUST BE in computation) OR
# - absolute distance pass OR
# - relative distance pass OR
# - ulp distance pass
naninf_success = np.logical_and(
np.isnan(self.computed), np.isnan(self.references)
).all()
)
metric_success = np.logical_or(
self.relative_distance_metric, self.absolute_distance_metric
)
metric_success = np.logical_or(metric_success, self.ulp_distance_metric)
success = np.logical_and(naninf_success, metric_success)
success = np.logical_or(naninf_success, metric_success)
return success
elif self.references.dtype in (np.bool_, bool):
success = np.logical_xor(self.computed, self.references)
Expand Down

0 comments on commit 9faa405

Please sign in to comment.