Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: address review on the AUROC warning filter
Add the pytest filterwarnings form, drop the structured_model.py
attribution and the 'once per process' claim, document the second
UserWarning with its own filter, add a CHANGELOG entry and a test that
the documented filters silence both warnings.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
  • Loading branch information
pcbeingused33 and claude committed Nov 4, 2026
commit 81e87cf75a7610fcd394678be830ecfba3d324ac
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Each release links to full notes on the

## [Unreleased]

### Fixed

- The docs recipe for silencing the `auroc_confidence_metric`
`DeprecationWarning` never matched it (it filtered on the comparison engine
module). It now filters by message, adds the pytest `filterwarnings` form, and
names the second `UserWarning` that `compare_with(add_confidence_metrics=True)`
emits.

## [1.0.1] - 2026-11-02

### Changed
Expand Down
23 changes: 21 additions & 2 deletions docs/docs/Guides/Evaluation/confidence-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ See [Bulk Evaluation: Map/Reduce](bulk-evaluation.md#mapreduce-single-doc-compar

## Silencing the legacy AUROC deprecation warning

`compare_with(add_confidence_metrics=True)` also writes a legacy `auroc_confidence_metric` key and emits a `DeprecationWarning` once per process, whether or not you read that key. Read `confidence_metrics["overall"]["auroc"]["value"]` instead, and silence the warning by its message:
`compare_with(add_confidence_metrics=True)` also writes a legacy `auroc_confidence_metric` key and emits a `DeprecationWarning`, whether or not you read that key. Read `confidence_metrics["overall"]["auroc"]["value"]` instead, and silence the warning by its message:

```python
import warnings
Expand All @@ -138,7 +138,26 @@ warnings.filterwarnings(
)
```

The warning is attributed to `structured_model.py` rather than to the comparison engine, so a `module=` filter on the comparison engine does not match it. Filtering by message keeps unrelated `DeprecationWarning`s from other libraries (or other parts of stickler) visible.
Under pytest, a `warnings.filterwarnings(...)` call in your code does not silence it, because pytest applies its own warning filters around each test. Put the same filter in your pytest configuration instead:

```toml
[tool.pytest.ini_options]
filterwarnings = [
"ignore:The 'auroc_confidence_metric' result key is deprecated:DeprecationWarning",
]
```

The same call also emits a `UserWarning` ("Single-document confidence metrics are a quick sanity check..."). The filter above does not cover it; silence it with its own filter:

```python
warnings.filterwarnings(
"ignore",
message="Single-document confidence metrics are a quick sanity check",
category=UserWarning,
)
```

Filtering by message keeps unrelated `DeprecationWarning`s from other libraries (or other parts of stickler) visible.

## Further Reading

Expand Down
51 changes: 51 additions & 0 deletions tests/test_confidence_warning_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""The warning filters documented in confidence-evaluation.md must silence the warnings."""

import warnings

import pytest

from stickler import StructuredModel
from stickler.utils import deprecation


class _Doc(StructuredModel):
a: str = "x"


@pytest.fixture(autouse=True)
def _fresh_sentinels(monkeypatch):
monkeypatch.setattr(deprecation, "_warned", set())


def _recorded(*filters):
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
for kwargs in filters:
warnings.filterwarnings("ignore", **kwargs)
_Doc().compare_with(_Doc(), add_confidence_metrics=True)
return caught


AUROC = {
"message": "The 'auroc_confidence_metric' result key is deprecated",
"category": DeprecationWarning,
}
SINGLE_DOC = {
"message": "Single-document confidence metrics are a quick sanity check",
"category": UserWarning,
}


def test_without_filters_both_warnings_are_emitted():
categories = {w.category for w in _recorded()}
assert {DeprecationWarning, UserWarning} <= categories


def test_documented_filters_silence_both_warnings():
assert _recorded(AUROC, SINGLE_DOC) == []


def test_auroc_filter_leaves_the_user_warning():
categories = [w.category for w in _recorded(AUROC)]
assert DeprecationWarning not in categories
assert UserWarning in categories