Repository navigation
Mark only the T case as xfail in the logscore distribution test - #437
Merged
Merged
Conversation
test_dists_runs_on_examples_logscore passed a function object as the condition of its xfail marker. pytest treats a non-string condition as a truth value, and a function is always true, so every distribution and learner in the test was marked xfail. A real failure in any of them would have shown as xfailed, and the passing cases showed as xpassed with --slow. The xfail now sits on the T case alone, through pytest.param. The marker is strict and only accepts ValueError, because NGBRegressor(Dist=T) with default settings fails for both learners with "Input y contains NaN" (the natural gradient for log df runs away as df grows, see #275). The unused is_t_distribution helper is removed. Found while assessing #168. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
ryan-wolbeck
self-requested a review
November 7, 2026 23:25
ryan-wolbeck
approved these changes
Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while assessing #168 (PR #433).
test_dists_runs_on_examples_logscoreintests/test_distns.pyhad this marker:is_t_distributionis a function, and pytest reads a non-stringconditionas a truth value. A function object is always true. So the test was marked xfail for every distribution and every learner, not forTalone. A real failure inNormal,Gamma,Weibullor any other case would have shown asxfailedand passed CI. With--slow, the 22 passing cases showed up asxpassed, which is the visible sign of the problem.Change
Tcase in thedistparametrize list is nowpytest.param(T, marks=pytest.mark.xfail(...)). The marker on the test function and theis_t_distributionhelper are gone.NGBRegressor(Dist=T)with default settings raisesValueError: Input y contains NaNfromfit, because the natural gradient for log df runs away as df grows.np.exp(params[2])overflows, and the NaN reaches the base learner.strict=True, becauseTfails for both learners. IfTstarts to pass, the run fails and the marker has to be removed. I checked that the failure is the same on Python 3.9, 3.12 and 3.14 (the ends and the middle of the CI matrix), so a strict marker should not flip on one CI job.raises=ValueError. A different exception from theTcase now counts as a real failure.I checked the rest of
tests/for the same pattern. This was the onlyxfail. Theskipifconditions intest_helpers.pyandtest_pickling.pycall their helper (not _sklearn_has_missing_go_to_left()), so they are real booleans.Tests
All runs use Python 3.12 and scikit-learn 1.6 with
--slow.tests/test_distns.py::test_dists_runs_on_examples_logscore, 24 cases (12 distributions, 2 learners):T, both learnersraises=ValueError)No case fails after the change. No distribution other than
Twas hiding a failure.Full suite:
The before counts come from two runs on an unmodified export of
origin/master:tests/test_distns.pyalone (28 passed, 2 xfailed, 22 xpassed) and the rest of the suite (140 passed, 1 skipped). The after count is one run of the whole suite.Lint on
tests/test_distns.pyis clean:black --check(24.10.0),isort --check-only, andpylintwith the options from.pre-commit-config.yaml(10.00/10).flake8in that config only coversngboost/.🤖 Generated with Claude Code