Skip to content

FIX DUMMY: avoid spurious out-of-range threshold warning - #17

Open
JayeshSuryavanshi wants to merge 1 commit into
KulikDM:mainfrom
JayeshSuryavanshi:fix/dummy-spurious-threshold-warning
Open

FIX DUMMY: avoid spurious out-of-range threshold warning#17
JayeshSuryavanshi wants to merge 1 commit into
KulikDM:mainfrom
JayeshSuryavanshi:fix/dummy-spurious-threshold-warning

Conversation

@JayeshSuryavanshi

Copy link
Copy Markdown

Submissions Basics:

Type of Change:

  • Bug fix

All Submissions Cores:

  • Added an explanation of what the changes do and why (below).
  • Written new unit tests for the change.
  • All new and existing unit tests pass locally.

What & why

DUMMY emits a spurious UserWarning ("Computed threshold 1.0000000000000002 is outside the range of 0 and 1") on every default call — the repo's own suite triggers it 10 times, all from tests/test_dummy.py.

Decision scores are min-max normalized to [0, 1], so np.percentile(decision, perc) is in [0, 1]. eval adds eps (limit = percentile + eps) so the top-scoring point stays an inlier at contam=0 (cut uses decision >= limit). It then passed that eps-bumped limit to _check_threshold, so a maximum percentile (== 1) made limit == 1 + eps > 1 and tripped the range guard — even though the threshold is valid and the labels are correct.

This validates the in-range percentile with _check_threshold instead of the eps-bumped limit. The stored thresh_ and the returned labels are unchanged (all pre-existing DUMMY tests still pass); only the spurious warning is gone.

  • Added tests/test_dummy.py::test_no_spurious_threshold_warning, asserting no out-of-range warning across the contam grid.
  • Added a CHANGES.txt entry (happy to retag the version if you'd prefer a different one).

ruff check clean; pytest tests/test_dummy.py → 20 passed, 0 warnings.

DUMMY.eval adds eps to the percentile threshold so the top-scoring point
stays an inlier at contam=0 (cut uses decision >= limit), but passed the
eps-bumped limit to _check_threshold. When the percentile is the maximum
(== 1 on min-max normalized scores), limit == 1 + eps > 1 and tripped the
"threshold outside the range" warning on every default call (the test
suite triggered it 10 times, all from tests/test_dummy.py).

Validate the in-range percentile instead; the stored thresh_ and the
returned labels are unchanged. Adds a regression test.
@JayeshSuryavanshi

Copy link
Copy Markdown
Author

Hi @KulikDM — this fixes #16 (the spurious out-of-range warning DUMMY emits on every default call); small and test-only, with a regression test. Ready for review whenever you have a moment — thanks!

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.

DUMMY thresholder emits a spurious 'threshold outside the range' warning on every default call

1 participant