Skip to content

BUG: Let set_smooth_method set the smooth_univariate flag - #11052

Merged
bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-ss-smooth-univariate-method
Nov 24, 2026
Merged

bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-ss-smooth-univariate-method

Conversation

@bashtage

Copy link
Copy Markdown
Member

Based on main. Conflicts with #11036 (filter option flags) only in test_options.py, where both append: keep both blocks and both imports.

KalmanSmoother.set_smooth_method(**kwargs) sets the boolean flags named in
KalmanSmoother.smooth_methods, which listed smooth_conventional,
smooth_alternative and smooth_classical but not smooth_univariate,
although SMOOTH_UNIVARIATE is documented in its Notes and the
smooth_univariate attribute exists. set_smooth_method(smooth_univariate=
True) therefore did nothing, and smooth_univariate=True as a constructor
argument (of KalmanSmoother, or of a model such as SARIMAX) raised
"TypeError: Unknown keyword arguments: ['smooth_univariate']".

Changes

  • smooth_univariate is added to KalmanSmoother.smooth_methods, so
    set_smooth_method and the constructors accept it like the other
    smoothing flags.
  • The univariate smoother needs the univariate filter (smoothing raises
    "Invalid smoothing method" otherwise, as it does when the
    smooth_univariate attribute is set). Without univariate filtering,
    set_smooth_method(smooth_univariate=True) ran on main and smoothed with
    the default method, so it still ignores the flag there, now with a
    FutureWarning that the flag will be set (and smoothing will raise) after
    statsmodels 0.17 is released.
  • The set_smooth_method docstring has a versionchanged note.

Not changed

  • Results: with univariate filtering, univariate smoothing is already the
    default, so setting the flag gives the same output.
  • The other smoothing flags, the default smoothing method, and setting the
    smooth_univariate attribute directly.

Tests (appended to test_options.py)

  • set_smooth_method(smooth_univariate=True), and the constructor argument,
    set the same bitmask as setting the attribute with univariate filtering,
    and False clears it; with the flag set, smoothing gives the output of
    the default smoothing method.

  • Without univariate filtering, both warn, leave the flag unset and
    smoothing gives main's output; the attribute still makes smoothing
    raise; False and the other flags do not warn.

  • 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.

  • No AI tools were used to develop this pull request.
  • AI tools were 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

KalmanSmoother.set_smooth_method(**kwargs) sets the boolean flags named in
KalmanSmoother.smooth_methods, which listed smooth_conventional,
smooth_alternative and smooth_classical but not smooth_univariate,
although SMOOTH_UNIVARIATE is documented in its Notes and the
smooth_univariate attribute exists. set_smooth_method(smooth_univariate=
True) therefore did nothing, and smooth_univariate=True as a constructor
argument (of KalmanSmoother, or of a model such as SARIMAX) raised
"TypeError: Unknown keyword arguments: ['smooth_univariate']".

Changes
- smooth_univariate is added to KalmanSmoother.smooth_methods, so
  set_smooth_method and the constructors accept it like the other
  smoothing flags.
- The univariate smoother needs the univariate filter (smoothing raises
  "Invalid smoothing method" otherwise, as it does when the
  smooth_univariate attribute is set). Without univariate filtering,
  set_smooth_method(smooth_univariate=True) ran on main and smoothed with
  the default method, so it still ignores the flag there, now with a
  FutureWarning that the flag will be set (and smoothing will raise) after
  statsmodels 0.17 is released.
- The set_smooth_method docstring has a versionchanged note.

Not changed
- Results: with univariate filtering, univariate smoothing is already the
  default, so setting the flag gives the same output.
- The other smoothing flags, the default smoothing method, and setting the
  smooth_univariate attribute directly.

Tests (appended to test_options.py)
- set_smooth_method(smooth_univariate=True), and the constructor argument,
  set the same bitmask as setting the attribute with univariate filtering,
  and False clears it; with the flag set, smoothing gives the output of
  the default smoothing method.
- Without univariate filtering, both warn, leave the flag unset and
  smoothing gives main's output; the attribute still makes smoothing
  raise; False and the other flags do not warn.
@bashtage
bashtage force-pushed the wip-ss-smooth-univariate-method branch from 6fccf0a to 4c4106a Compare November 24, 2026 11:48
@bashtage
bashtage marked this pull request as ready for review November 24, 2026 23:23
@bashtage
bashtage merged commit 4f87288 into statsmodels:main Nov 24, 2026
11 of 12 checks passed
@bashtage
bashtage deleted the wip-ss-smooth-univariate-method branch November 24, 2026 23:23
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