Skip to content

REF: Remove unreachable code in NewsResults - #11082

Draft
bashtage wants to merge 1 commit into
statsmodels:mainfrom
bashtage:wip-news-unreachable
Draft

bashtage wants to merge 1 commit into
statsmodels:mainfrom
bashtage:wip-news-unreachable

Conversation

@bashtage

@bashtage bashtage commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

#11080 and #11078, which this PR was stacked on, are merged. No conflict with #11054, #11057, #11058 or #11029. With the get_impacts PR, only the blocks that it and #11080 append to test_news.py conflict: keep both.

REF: Remove unreachable code in NewsResults

Remove three branches of statespace/news.py that no input reaches:

  • The except AttributeError around Series.map in the univariate block of
    summary_impacts: Series.map exists in every pandas version (it fell back
    to Series.applymap, which never existed). The pandas < 2.1 fallbacks
    around DataFrame.map are kept; the minimum-versions job runs them.
  • if self.revisions_details_start > 0 in _revision_grouped_impacts: it is
    only called when some revisions are grouped, and revisions are grouped
    only if they are before revisions_details_start > 0
    (SmootherResults.news), which only increases afterwards.
  • if key in details for the data columns in summary_details: the
    observed (revised), previous, news (revision), weight and impact
    columns are always in the table; only the date and variable keys can be
    moved to the title.

Not changed

  • Any result: the remaining code is what ran before.

Tests

  • test_news.py passes unchanged on pandas 3.0.5 and 2.3.3 with -W error.

  • 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 unreachable code in a coverage audit, removing it, and checking that the 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

Remove three branches of statespace/news.py that no input reaches:

- The except AttributeError around Series.map in the univariate block of
  summary_impacts: Series.map exists in every pandas version (it fell back
  to Series.applymap, which never existed). The pandas < 2.1 fallbacks
  around DataFrame.map are kept; the minimum-versions job runs them.
- if self.revisions_details_start > 0 in _revision_grouped_impacts: it is
  only called when some revisions are grouped, and revisions are grouped
  only if they are before revisions_details_start > 0
  (SmootherResults.news), which only increases afterwards.
- if key in details for the data columns in summary_details: the
  observed (revised), previous, news (revision), weight and impact
  columns are always in the table; only the date and variable keys can be
  moved to the title.

Not changed
- Any result: the remaining code is what ran before.

Tests
- test_news.py passes unchanged on pandas 3.0.5 and 2.3.3 with -W error.
@bashtage
bashtage force-pushed the wip-news-unreachable branch from 1f397ad to 450b84c Compare November 28, 2026 22: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