Repository navigation
Conversation
This was referenced Nov 23, 2026
Member
Author
|
Merge order. These open PRs build on this one (their branches contain its commits), so please merge this PR first: Once this PR is merged, their diffs shrink to their own changes. Each of them also says "Stacked on #..." at the top of its description. Merge-order note generated with Claude Code (updated 2026-11-25). |
4 of 5 tasks
bashtage
force-pushed
the
wip-ss-smoother-unreachable
branch
4 times, most recently
from
November 27, 2026 23:06
4a1657b to
071bf2d
Compare
Code that no public path reaches (found by the C9b coverage work on
kalman_smoother.py, tools.py and simulation_smoother.py):
kalman_smoother.py
- KalmanSmoother._smooth: the check that the filter or the representation
was just re-created. _smooth is only called by smooth() right after
_filter() with the same arguments, so neither is ever re-created.
- SmootherResults._smoothed_state_autocovariance: the `extend_kwargs is
None` default. Its only caller always passes a dict, so the argument is
now required.
- SmootherResults.news: the out-of-sample prediction for the total
revision impacts. The revision model is built through
max(end, previous.nobs), so `end` never exceeds its sample.
tools.py
- constrain_stationary_multivariate: the `k_endog < 1` check. A zero
k_endog fails earlier, in `order //= k_endog`.
- _unconstrain_sv_less_than_one: the defaults of `order` and `k_endog`
(always passed); they are now required.
- _compute_multivariate_pacf_from_autocovariances: the `order` and
`k_endog` arguments, which no caller passes (k_endog was not used).
- _compute_multivariate_pacf_from_coefficients: the `order` and `k_endog`
arguments, which were recomputed from the matrices, and the branch for an
array of matrices (its only caller passes a list).
- _compute_multivariate_acovf_from_coefficients: the branch for an array
of matrices and the `forward_autocovariances` argument (its only caller
passes a list and backward autocovariances). The existing direct test
passes lists and does not change.
- copy_missing_matrix, copy_missing_vector, copy_index_matrix and
copy_index_vector: the blocks that kept an F-contiguous Cython
memoryview unconverted. All callers pass ndarrays, so the source is
always converted with np.require, as before.
- _atleast_1d is only called with one input and _atleast_2d with five, so
_atleast_1d takes one input and returns its array, and _atleast_2d
always returns a list.
simulation_smoother.py
- The simulate() error for a changed representation named the
template-literal class `_{{prefix}}Representation`; it now says "the
underlying compiled representation model object".
Not changed: results and errors of all public functions.
_safe_cond keeps its inf branch: with numpy's own LAPACK, np.linalg.cond
only fails for NaN entries, but other LAPACK builds may fail to converge
for inf entries.
Tests: no new tests; the statespace suite passes. Coverage of the
statespace tests: kalman_smoother.py 93.5/84.8% to 94.3/85.7% (lines /
branches), tools.py 93.7/83.6% to 96.4/90.4%.
SmootherResults.news(design=...) documented `design` as the design matrix for period `t` that a time-varying model needs when `t` is outside of its sample. It had no effect: news raises a RuntimeError for impacts on periods outside of the sample of a time-varying model, and otherwise the design matrix of the results object is used, so the branches that read `design` could not be reached. Changes: - Passing `design` raises a FutureWarning; it will be removed after statsmodels 0.17 is released. The docstring says that it is not used. - The unreachable branches that read `design` are removed. Not changed: the results of news, with or without `design`. Tests (appended to test_smoothing.py): for a time-invariant and a time-varying model, news(design=...) warns, from the caller, and the update impacts with and without `design` equal the change in the smoothed forecasts that the new observations cause.
bashtage
force-pushed
the
wip-ss-smoother-unreachable
branch
from
November 28, 2026 21:36
071bf2d to
c7332e2
Compare
The release after 0.15.0 is 0.16.0, not 0.15.1, so the design argument is deprecated in 0.16.0. Move its removal one release later, to after statsmodels 0.18 is released, as xref statsmodels#11327 does for the deprecations that named 0.17.
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.
Two commits; the details are in each. Based on main; #11025 (the C9b coverage chunk) changes docstrings of the same files and appends to the same test files, so whichever merges second needs a rebase. With #11025: only
test_smoothing.py, keep both blocks. The other C9F-B PRs that append totest_smoothing.py(smooth arguments, smoother output, autocovariance cache, smoother unreachable code) conflict there too: keep every appended block and the union of the imports.REF: Remove unreachable code in the statespace smoother and tools
Code that no public path reaches (found by the C9b coverage work on
kalman_smoother.py, tools.py and simulation_smoother.py):
kalman_smoother.py
was just re-created. _smooth is only called by smooth() right after
_filter() with the same arguments, so neither is ever re-created.
extend_kwargs is Nonedefault. Its only caller always passes a dict, so the argument isnow required.
revision impacts. The revision model is built through
max(end, previous.nobs), so
endnever exceeds its sample.tools.py
k_endog < 1check. A zerok_endog fails earlier, in
order //= k_endog.orderandk_endog(always passed); they are now required.
orderandk_endogarguments, which no caller passes (k_endog was not used).orderandk_endogarguments, which were recomputed from the matrices, and the branch for an
array of matrices (its only caller passes a list).
of matrices and the
forward_autocovariancesargument (its only callerpasses a list and backward autocovariances). The existing direct test
passes lists and does not change.
copy_index_vector: the blocks that kept an F-contiguous Cython
memoryview unconverted. All callers pass ndarrays, so the source is
always converted with np.require, as before.
_atleast_1d takes one input and returns its array, and _atleast_2d
always returns a list.
simulation_smoother.py
template-literal class
_{{prefix}}Representation; it now says "theunderlying compiled representation model object".
Not changed: results and errors of all public functions.
_safe_cond keeps its inf branch: with numpy's own LAPACK, np.linalg.cond
only fails for NaN entries, but other LAPACK builds may fail to converge
for inf entries.
Tests: no new tests; the statespace suite passes. Coverage of the
statespace tests: kalman_smoother.py 93.5/84.8% to 94.3/85.7% (lines /
branches), tools.py 93.7/83.6% to 96.4/90.4%.
DEP: Deprecate the unused design argument of SmootherResults.news
SmootherResults.news(design=...) documented
designas the design matrixfor period
tthat a time-varying model needs whentis outside of itssample. It had no effect: news raises a RuntimeError for impacts on
periods outside of the sample of a time-varying model, and otherwise the
design matrix of the results object is used, so the branches that read
designcould not be reached.Changes:
designraises a FutureWarning; it will be removed afterstatsmodels 0.18 is released. The docstring says that it is not used.
designare removed.Not changed: the results of news, with or without
design.Tests (appended to test_smoothing.py): for a time-invariant and a
time-varying model, news(design=...) warns, from the caller, and the
update impacts with and without
designequal the change in the smoothedforecasts that the new observations cause.
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 unreachable code in a coverage audit, removing it, deprecating the argument that has no effect, writing the tests, and checking that results do not change.
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