[BUG] Replace bare print with warning on non-convergence, fix ValueError format#571
Open
tarun-227 wants to merge 2 commits intodswah:mainfrom
Open
[BUG] Replace bare print with warning on non-convergence, fix ValueError format#571tarun-227 wants to merge 2 commits intodswah:mainfrom
tarun-227 wants to merge 2 commits intodswah:mainfrom
Conversation
- Replace `print("did not converge")` with `warnings.warn()` so that
non-convergence is surfaced through Python's warning system instead of
printing to stdout. This allows users to filter/capture the message
programmatically.
- Fix string formatting bug in `_estimate_GCV_UBRE` where `format(gamma)`
was passed as a separate argument to `ValueError` instead of being
interpolated into the message string, resulting in a confusing tuple
error message like `('msg {}', '0.5')`.
2afcac1 to
3ce140a
Compare
3 tasks
Tushar8466
reviewed
Apr 3, 2026
Tushar8466
left a comment
There was a problem hiding this comment.
The [MNT] fix ruff-format commit (3ce140a) is failing —
the ruff formatting check is not passing.
You may need to run ruff locally and fix the formatting before this can be merged:
ruff format pygam/
ruff check pygam/ --fix
git add .
git commit -m "fix: ruff formatting"
git push origin fix/convergence-warning-and-format-bugOnce that's resolved, this looks good to merge! ✅
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.
Summary
Two bugs found by code review:
print("did not converge")→warnings.warn()(pygam.py:821)print()for user-facing messages. Replaced withwarnings.warn()so users can programmatically capture/filter non-convergence events via Python's warning system.Malformed
ValueErrorin_estimate_GCV_UBRE(pygam.py:1196-1199)format(gamma)was passed as a separate argument toValueErrorinstead of being interpolated into the string. This produced a confusing tuple error message:Test plan
test_non_convergence_emits_warning— verifies warning is emitted (not printed)test_GCV_UBRE_gamma_error_message— verifies error message contains the actual gamma value