Skip to content

TST: Follow up on #10590, test MNLogit and the one-row case of predict - #10594

Merged
bashtage merged 1 commit into
statsmodels:mainfrom
bashtage:wip-fu-10590
Oct 26, 2026
Merged

bashtage merged 1 commit into
statsmodels:mainfrom
bashtage:wip-fu-10590

Conversation

@bashtage

Copy link
Copy Markdown
Member
  • closes #xxxx
  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.

Follow up to #10590.

Tests (statsmodels/base/tests/test_predict.py)

  • test_predict_series_mnlogit: MNLogit with one exog column has params.size == 2 and a DataFrame result with one column per category. The expected probabilities are computed from the fitted parameters with a softmax, and the index of the Series is checked for one and three observations. Both cases fail with the old condition params.size == 1 and pass now.
  • test_predict_series_is_one_row_with_two_exog: a Series is still one observation for a model with two exog columns, which is the other side of the condition on exog.shape[1].
  • A comment on test_formula_series_after_remove_data says that these cases also pass without the change of the condition and protect the guard for a model without exog.

Release note

  • The bullet in version0.15.1.rst has the :pr: role, and names the other models that were affected (GeneralizedPoisson, ZeroInflatedPoisson, BetaModel, MNLogit).

Not changed

  • The idiom exog.shape[1] == 1 is written in three places (base/model.py twice and base/_prediction_inference.py); a helper is not worth a change here.
  • Pre-existing: a Series row for a multi-column model gets the index [exog.index.name], and a non-formula Series after remove_data() raises an AttributeError.

Verified: test_predict.py 22 passed (Python 3.13, NumPy 2.5.4, SciPy 1.18.1); ruff check clean.

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.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude Code (Claude Sonnet 5.5).
    Used for: reviewing the merged PR across 13 model types, and drafting the tests and release note.
    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

Add MNLogit, which has two sets of parameters and a DataFrame result, to the
tests of predict with a Series, and a test that a Series is still one
observation when the model has two exog columns. Say what the tests of the
formula models after remove_data protect. Add the :pr: role and the other
affected models to the release note.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@bashtage
bashtage marked this pull request as ready for review October 26, 2026 17:06
@bashtage
bashtage merged commit 8845c17 into statsmodels:main Oct 26, 2026
12 of 13 checks passed
@bashtage
bashtage deleted the wip-fu-10590 branch October 26, 2026 17:06
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.

1 participant