Repository navigation
BUG: Accept leading flags positionally in MLEModel loglike, score, hessian - #11043
Merged
bashtage merged 2 commits intoNov 27, 2026
Merged
Conversation
bashtage
force-pushed
the
wip-mlemodel-positional-flags
branch
from
November 22, 2026 23:55
96237d5 to
cc1b20d
Compare
This was referenced Nov 23, 2026
bashtage
force-pushed
the
wip-mlemodel-positional-flags
branch
4 times, most recently
from
November 26, 2026 11:46
7308e97 to
ca0cf3d
Compare
…ssian
MLEModel.loglike, score and hessian take their flags (transformed,
includes_fixed, ...) as *args, so that fit can pass them to the optimizer
as a single dictionary. Since 0.15.0, a positional call with fewer flags
than the method has, such as mod.loglike(params, False), raised
"ValueError: zip() argument 2 is shorter than argument 1", because the zip
that maps the positional values to the flag names was made strict.
statsmodels 0.14 accepted any number of leading flags. This is a
regression in 0.15.0.
Changes
- Any number of leading flags can again be given positionally; the other
flags take their defaults.
- The flags after the positional ones can be given by keyword, as for an
ordinary function: mod.loglike(params, False, complex_step=True). Once
any flag was positional, the keyword flags were not read: 0.14 and 0.15.0
passed them on and raised a TypeError further down ("got multiple values
for keyword argument 'complex_step'", or "unexpected keyword argument
'approx_centered'" from score).
- More positional flags than the method has raise a TypeError that names
the flags. statsmodels 0.14 silently ignored the extra values, and
0.15.0 raised the ValueError from zip.
- A flag given both positionally and by keyword raises "got multiple values
for keyword argument '<name>'" from score and hessian as well; the
message started with "loglike()" for all three methods.
Not changed
- Calls with the flags by keyword, with all of the flags positionally, or
with the dictionary that fit passes.
- loglikeobs and score_obs, which have ordinary signatures.
Tests
- For loglike, loglikeobs, score, score_obs and hessian, every number of
leading positional flags, with values that differ from the defaults,
gives the same result as the keyword form, with the remaining flags
either left at their defaults or given by keyword. The calls of loglike,
score and hessian with some but not all flags fail on main.
- One flag too many raises a TypeError for each method;
test_hessian_positional_flags expects the TypeError instead of the
ValueError from zip.
- A flag given both ways raises the TypeError for each method.
bashtage
force-pushed
the
wip-mlemodel-positional-flags
branch
from
November 27, 2026 00:30
ca0cf3d to
1e53e37
Compare
bashtage
marked this pull request as ready for review
November 27, 2026 21:34
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.
Fixes a regression in 0.15.0. #11029 (the C10 coverage chunk) appends tests to the same test file, so whichever merges second needs a rebase (keep both test blocks).
MLEModel.loglike, score and hessian take their flags (transformed,
includes_fixed, ...) as *args, so that fit can pass them to the optimizer
as a single dictionary. Since 0.15.0, a positional call with fewer flags
than the method has, such as mod.loglike(params, False), raised
"ValueError: zip() argument 2 is shorter than argument 1", because the zip
that maps the positional values to the flag names was made strict.
statsmodels 0.14 accepted any number of leading flags. This is a
regression in 0.15.0.
Changes
flags take their defaults.
ordinary function: mod.loglike(params, False, complex_step=True). Once
any flag was positional, the keyword flags were not read: 0.14 and 0.15.0
passed them on and raised a TypeError further down ("got multiple values
for keyword argument 'complex_step'", or "unexpected keyword argument
'approx_centered'" from score).
the flags. statsmodels 0.14 silently ignored the extra values, and
0.15.0 raised the ValueError from zip.
for keyword argument ''" from score and hessian as well; the
message started with "loglike()" for all three methods.
Not changed
with the dictionary that fit passes.
Tests
For loglike, loglikeobs, score, score_obs and hessian, every number of
leading positional flags, with values that differ from the defaults,
gives the same result as the keyword form, with the remaining flags
either left at their defaults or given by keyword. The calls of loglike,
score and hessian with some but not all flags fail on main.
One flag too many raises a TypeError for each method;
test_hessian_positional_flags expects the TypeError instead of the
ValueError from zip.
A flag given both ways raises the TypeError for each method.
tests added / passed.
code/documentation is well formatted.
properly formatted commit message. See
NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Code (Claude Opus 5.5).
Used for: finding the bug in a contract audit, writing the fix and its tests, and checking them (tests failing on main, mutation check).
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
🤖 Generated with Claude Code