Skip to content

rust: prevent overflow in pairwise metric denominators #960

Closed

Description

@athvin

Evidence

pairwise_metrics_from_counts adds u64 counts before converting to f64. For tp = u64::MAX, fp = 1, debug builds panic and release builds wrap. Source.

Change

Compute denominators without u64 overflow while retaining the existing empty-set conventions.

Done when

  • Boundary counts near u64::MAX do not panic.
  • Precision, recall, and F1 are finite and in [0, 1] for valid counts.

Activity

  1. added
    code-cleanup
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-cleanup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions