Skip to content

fix: correct RetrievalAUROC max_fpr validation logic - #3450

Closed
xiaoyaoqilan wants to merge 1 commit into
Lightning-AI:masterfrom
xiaoyaoqilan:fix/auroc-max-fpr-validation
Closed

fix: correct RetrievalAUROC max_fpr validation logic#3450
xiaoyaoqilan wants to merge 1 commit into
Lightning-AI:masterfrom
xiaoyaoqilan:fix/auroc-max-fpr-validation

Conversation

@xiaoyaoqilan

Copy link
Copy Markdown

Problem

RetrievalAUROC.__init__ has two issues in its max_fpr validation:

if max_fpr is not None and not isinstance(max_fpr, float) and 0 < max_fpr <= 1:

Bug 1: The and chain short-circuits when isinstance(max_fpr, float) is True, so out-of-range float values (e.g. 2.0, 0.0) silently pass without raising ValueError.

Bug 2: Non-numeric types (e.g. max_fpr="abc") cause TypeError on 0 < max_fpr instead of a helpful ValueError.

Bug 3: Integer values like max_fpr=1 fail isinstance(max_fpr, float), even though they are reasonable inputs.

Fix

Restructure to use a negated compound condition with (float, int):

if max_fpr is not None and not (isinstance(max_fpr, (float, int)) and 0 < max_fpr <= 1):

This correctly:

  • Raises ValueError for non-numeric types (no TypeError)
  • Raises ValueError for out-of-range values
  • Accepts both float and int values
  • Skips validation for None (optional parameter)

Co-Authored-By: Claude noreply@anthropic.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant