Repository navigation
BUG: Allow NewsResults summaries of dates without impacts above the tolerance - #11118
Merged
bashtage merged 13 commits intoNov 25, 2026
Merged
Conversation
Add tests of the paths of statespace/news.py that the TSA test suite did not reach, each checked against an independent value: - closed forms for an AR(1) model with a revision and an update: the weights, revisions, news and impacts of revision_details_by_impact (with all revisions detailed) and details_by_impact, and the estimates of the impacts table; with two updates, the details table of each update date; - the details tables summed over the revisions or updates give the revision and update impacts, and these add up to the change in the estimates, with detailed and with grouped revisions; - impacted_variable (str, list, array and slice, given to news or set on the results) and tolerance (set on the results) select the rows of every details table and of the impacts table; - summary_impacts, summary_details, summary_news and summary_revisions: every cell of the tables against the DataFrames they show (the AR(1) closed forms for the univariate details), with and without sparsifying, with each groupby (and its underscore spelling), the impact and update date and variable selections, multiple tables, the univariate defaults, show_revisions_columns, the weights shown as 1.0 and 0, equal values of different variables (not blanked), and the errors for an invalid groupby; - summary: the header (samples, revisions, new datapoints, included states) and its tables against the individual summary methods with every argument (including the revision date and revised variable of the details of revisions), for univariate and multivariate models; - state_index: in a VAR(1) the impacts of the news and the detailed impacts of the revisions through the first state are those of the first variable; - get_details and get_impacts with each include flag (summing to the matching impacts), and get_impacts with a groupby of the updated variables. Two bugs of NewsResults, not fixed here, shape the tests: the univariate summaries are tested with a one-letter series name (k_endog is the length of the name of the series of a univariate model), and test_get_impacts_groupby ignores the two FutureWarnings that pandas < 3 raises in get_impacts with a groupby (stack without future_stack). Coverage of news.py by the TSA tests goes from 85.6% to 97.0% of the lines and from 63.9% to 98.3% of the branches.
Fix the docstrings of statespace/news.py where they disagree with the code. No code changes. - get_impacts: `groupby` groups the updated (or revised) variables separately for each update date, for example with a dict or a function of the variable names; it is not applied to the combined details table and cannot group the update dates, which the docstring gave as its example (that raises a KeyError). The index of the result has the levels `update date` and `updated variable` (or the groups). - get_details also renames the index levels of the revision details, and both get_details and get_impacts return an empty table if both include flags are False. - summary_news has a `news` column; the columns of data_updates, data_revisions, details_by_impact and revision_details_by_impact and the index levels of details_by_update and revision_details_by_update are listed in their actual order; the details tables and impacts only include the rows above `tolerance` and of the selected `impacted_variable`. - impacted_variable and tolerance (settable properties) get docstrings. - summary_details: `updated_variable` are the variables that generated the news, not those affected by it, and with `source="revisions"`, `update_date`, `updated_variable` and `groupby` refer to the revision dates and revised variables. - summary: the news table is listed, the revisions tables are shown only with `include_revisions_tables=True` (default False) and only if the data were revised, and `revision_date` and `revised_variable` apply to the details tables of revisions. - NewsResults takes the results of SmootherResults.news (there is no KalmanSmoother.news).
summary_impacts (and the impacts table of summary) formats the impact dates and impacted variables as strings and writes them back with a block assignment (impacts.iloc[:, :2] = ...). pandas converts the strings back to the dtype of the column, so for a PeriodIndex or a DatetimeIndex the dates stay dates, and the sparsified (blanked) repeated dates were shown as "NaT" in every multivariate table grouped by impact date. For integer dates (data given as a list or an ndarray), pandas 3 raised "TypeError: Invalid value '...' for dtype 'int64'" (a FutureWarning on pandas 2.x), also for univariate models, so summary of such news raised. Changes - The formatted columns are assigned column by column, which replaces each column. Series.map exists in every supported pandas version, so the pandas < 2.1 fallback of the multivariate block (which made the same block assignment with applymap) is not needed any more. Not changed - The text of every table that did not show NaT; the first column of the univariate table is a column of str instead of dates, with the same text. The unreachable fallback around Series.map of the univariate block is left for a separate pull request. Tests - For univariate and multivariate models with a PeriodIndex, a DatetimeIndex and integer dates, with and without sparsifying, every cell of summary_impacts is that of the impacts DataFrame (the repeated dates blank), and summary shows the same table. On the base, the multivariate sparsified cases with dates fail, and the integer cases fail on pandas 3 (warn on pandas 2.3).
…mpacts summary_impacts selects the rows of the impacts table with impacts.loc[(impact_date, impacted_variable), :]. If both are single labels, this is a complete key of the MultiIndex, and pandas returns the row as a Series, so the table code raised "AttributeError: 'Index' object has no attribute 'remove_unused_levels'", for example for news.summary_impacts(impact_date="2009Q3", impacted_variable="unemp") or news.summary(impact_date="2009Q3", impacted_variable="unemp"). Univariate models whose series has a one-letter name select their variable by default, so any single impact date raised for them, also a partial date string such as "2009". Changes - The rows are selected by their positions from MultiIndex.get_locs, which is what .loc uses for every key that is not a complete key, so a single impact date and variable give a table with one row (or the rows of a partial date string). Not changed - Every other selection selects the same rows, and a label that is not in the table still raises a KeyError (with the label alone as the message instead of the tuple). Tests - For a single impact date given as a string, as a Period and as a partial date string, with a single impacted variable of a multivariate model, and with and without the variable of a univariate model, the table shows the rows of the impacts DataFrame, summary shows the same table, and a date without impacts raises a KeyError. All cases fail on the base.
summary_impacts accepts groupby="impact_date" and "impacted_variable" as spellings of "impact date" and "impacted variable" (as summary_details does), but it sparsifies the first column only if groupby is the name of a column, so with the underscore spellings the repeated impact dates (or impacted variables) were not blanked. The title joins a single impacted variable or impact date that was moved out of the table with "on" if groupby == "date", which no valid groupby is, so it was always "for". Changes - groupby is normalised as in summary_details (lower case, underscores replaced by spaces) before it is used, so every spelling gives the same table. - The title says "Impacts on [impacted variable = ...]" when grouping by impact date (the default, so for example in the impacts table of every univariate model) and "Impacts for [impact date = ...]" when grouping by impacted variable. Not changed - The tables for groupby="impact date" and "impacted variable" apart from the title, and the error for an invalid groupby. Tests - For each spelling of both groupings, every cell of the table is that of the impacts DataFrame with the first column sparsified, and the title of a table with a single impacted variable or impact date. The underscore spellings and the title with "on" fail on the base.
…able summary_details(multiple_tables=True) makes one table for each value of the groupby key, which it looks up in a dict of the column names that only has the update (revision) date and variable. With groupby="impact date" or "impacted variable" it raised a KeyError, and so did summary(details_groupby="impact date") (or "impacted variable") for every multivariate model, also with the default include_details_tables (summary makes the details tables even if it does not show them), and for univariate models whose series name is longer than one character. Changes - The dicts of column names of the news and revisions details include the impact date and the impacted variable, so there is one table for each impact date or impacted variable. Not changed - The tables of the other groupings and of a single table. Tests - For the news and the revisions, grouped by impact date and by impacted variable, there is a table for each key, whose cells are those of the details DataFrame for that key, and summary shows these tables. All cases fail on the base.
… model NewsResults set k_endog = len(self.endog_names), and endog_names of a univariate model is the name of the series (a str), so k_endog was the length of the name. The documented univariate defaults applied only to series with a one-letter name. For a series named "infl" (k_endog = 4), summary showed no details tables by default, include_details_tables=True gave one details table per update date, summary_details with multiple_tables=True kept the variable columns, and summary(details_groupby="impact date") raised a KeyError. Where they applied, the defaults selected the rows of the tables by the name of the variable, so for one-letter names summary raised a KeyError when there were no new observations or no impacts above the tolerance (an empty table), and with include_revisions_tables=True when all revisions were grouped (the default revisions_details_start=False); with some revisions grouped, the "all prior revisions" rows were silently dropped from the details of the revisions. Fixing k_endog alone would have made these errors happen for every univariate model. Changes - k_endog is the number of variables of the model. - The single variable of a univariate model no longer selects the rows of the tables: summary_impacts used it only to select the rows (a no-op otherwise), and summary_details treats it as selected, so that it is moved to the title of multiple tables. - summary leaves out a single details table without rows, as it does for multiple tables, so the summary of a univariate model without news (or without impacts above the tolerance) gains no empty table. - versionchanged in the docstring of summary. Results change for valid input of univariate models whose series name is longer than one character: summary shows the details tables by default, as documented, and a single details table for any details_groupby; summary_details(multiple_tables=True) shows the variable in the title; k_endog is 1. For one-letter names, the details of the revisions include the grouped revisions. Not changed - Multivariate models, and the tables of univariate models apart from the above. Tests - For a series named "infl" and "y", k_endog is 1, summary shows a single details table of the news and of the revisions by default for each grouping (also a table with a single row), and multiple tables show the variable in the title. - For both names, with revisions only (all grouped), with some revisions grouped, and with no impact above the tolerance, summary shows the expected tables (no empty details tables), and the details of the revisions include the grouped revisions and sum to the impacts of the revisions. These cases fail on the base for "y" (and with k_endog fixed alone, also for "infl"). - A multivariate model with news for a single variable keeps the updated variable in a column of multiple tables unless it is selected. - The univariate tests of statsmodels#11078 use the name of the series ("infl") instead of "y", which they used because of this bug, and test_summary_univariate runs with both names.
summary_impacts selected the impact dates and impacted variables given by impact_date and impacted_variable from the impacts table, which leaves out the rows whose impacts of news and of revisions are all within the tolerance. An impact date or impacted variable whose impacts were all within the tolerance therefore raised a KeyError, although a range of such dates gives a table without rows. For example, with an AR(1) of infl whose previous data end in 2009Q2 and news for 2009Q3 (impact dates 2009Q2-2009Q4), summary_impacts(impact_date="2009Q2") raised "KeyError: '2009Q2'" (the observed 2009Q2 has no impact of the news), and with tolerance=1e6, so did every impact date and impacted variable. A list with such a date raised as well, for example impact_date=["2009Q2", "2009Q3"]. Changes - The rows are selected before the rows within the tolerance are left out, so that such a date or variable selects no rows: the table has only the header, and a list gives the rows of the other dates. The impacts property and summary_impacts share the code of the impacts table (a private _get_impacts). Not changed - A label that is not an impact date or impacted variable still raises a KeyError, and the tables of selections with impacts above the tolerance are the same. - summary_details (and so summary) with such a date still raises a KeyError; see the next commit. Tests - For univariate (the observed date) and bivariate models (tolerance above every impact), selecting the date, the variable or both gives a table with only the header, where the impacts DataFrame has no rows for them; dates outside the impact dates and unknown variables still raise. A list with the observed date gives the row of the other date, with the values of the impacts DataFrame. All cases fail on the base with the KeyError (pandas 3.0; also checked with pandas 2.3.3).
summary_details selected the impact dates, impacted variables, update (or revision) dates and updated (or revised) variables given by its arguments from details_by_impact (or revision_details_by_impact), which leaves out the rows whose impact is within the tolerance. As in summary_impacts (previous commit), a date or variable whose impacts were all within the tolerance raised a KeyError, and so did summary, which passes impact_date and impacted_variable to both. For example, with the AR(1) of infl whose previous data end in 2009Q2 and news for 2009Q3, summary_details(impact_date="2009Q2") and summary(impact_date="2009Q2") raised "KeyError: '2009Q2'", and with tolerance=1e6, every selection of summary_details raised. Changes - The rows are selected before the rows within the tolerance are left out, so that such a date or variable selects no rows: the details table has only the header, and a list gives the rows of the other dates. summary leaves out the details tables without rows, as it does without a selection. The details_by_impact and revision_details_by_impact properties and summary_details share the code of the tables (private _get_details_by_impact and _get_revision_details_by_impact). Not changed - A label that is not in the details tables still raises a KeyError, and the tables of selections with impacts above the tolerance are the same. - A details table without any rows before the tolerance (the details of the news when there are only revisions) still raises a KeyError for a selected label, so summary(impact_date=...) of news with revisions only still raises (it builds the details of the news even if they are not shown). This has a different cause and is left for a separate fix. Tests - With a tolerance above every impact of the bivariate model, selecting an impact date, impacted variable, update (revision) date or updated (revised) variable gives the details of news and of revisions with only the header (the columns of the table without a selection); labels that are not in the tables still raise. - For the univariate model, the observed 2009Q2 gives a table with only the header, and a list with it gives the row of the other date, with the values of details_by_impact. - summary of such an impact date gives the impacts table with only the header and the tables of the news and revisions, without details tables, for both models. - All 11 cases fail on the previous commit with the KeyError (pandas 3.0 and 2.3.3).
The ValueError of summary_impacts for an invalid groupby ended with '"impacted variable".Got "..."', and that of summary_details with '"impact date",or "impacted variable"': the strings joined by implicit concatenation missed a space. Changes - The messages read '... "impacted variable". Got "..."' and '... "impact date", or "impacted variable". Got "..."'. Not changed - The type of the error and when it is raised. Tests - The message of each method for an invalid groupby equals the full text (fails on the previous commit).
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). |
bashtage
marked this pull request as ready for review
November 25, 2026 16:12
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 27, 2026
When the news has no updates (for example comparison_type="updated" with the same observations and a revision) or no revisions, its details table has no rows at all. Selecting from it, as summary_details(impact_date=..., impacted_variable=..., update_date=... or updated_variable=...) and summary(impact_date=...) do, raised a KeyError, because the label is not in the index of the empty table. statsmodels#11118 lets a label whose impacts are all within the tolerance select no rows; this is the case of a table without any rows. Stacked on statsmodels#11118 (selections of dates and variables whose impacts are all within the tolerance), which changes the same functions. Changes - The details tables of the news and of the revisions select the rows of the key only if they have rows, as they already did for the impacted variable of the results. Not changed - A label that is not in a details table with rows still raises a KeyError. Tests (test_news.py) - Without news (an "updated" comparison without new observations) and without revisions (an AR(1) with one new observation), each selection gives the details table with only its header, the same as without a selection. - summary(impact_date=...) without news has the impacts table of that date, the revisions table and the details of the revisions; the impacts of the revision of 2009Q3 from 0 are its observed value and half of it (phi = 0.5) for the forecast of 2009Q4. - All nine fail on statsmodels#11118.
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 28, 2026
When the news has no updates (for example comparison_type="updated" with the same observations and a revision) or no revisions, its details table has no rows at all. Selecting from it, as summary_details(impact_date=..., impacted_variable=..., update_date=... or updated_variable=...) and summary(impact_date=...) do, raised a KeyError, because the label is not in the index of the empty table. statsmodels#11118 lets a label whose impacts are all within the tolerance select no rows; this is the case of a table without any rows. Stacked on statsmodels#11118 (selections of dates and variables whose impacts are all within the tolerance), which changes the same functions. Changes - The details tables of the news and of the revisions select the rows of the key only if they have rows, as they already did for the impacted variable of the results. Not changed - A label that is not in a details table with rows still raises a KeyError. Tests (test_news.py) - Without news (an "updated" comparison without new observations) and without revisions (an AR(1) with one new observation), each selection gives the details table with only its header, the same as without a selection. - summary(impact_date=...) without news has the impacts table of that date, the revisions table and the details of the revisions; the impacts of the revision of 2009Q3 from 0 are its observed value and half of it (phi = 0.5) for the forecast of 2009Q4. - All nine fail on statsmodels#11118.
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.
#11080 and #11078, which this PR was stacked on, are merged. The first commit moves the selection of
summary_impactsthat #11080 changed (the single date and variable fix) into the shared code of the impacts table. No conflict innews.pywith #11081 or #11082 (also stacked on #11080). #11080, #11081 and the NewsResults get_impacts dict PR append tests at the end oftest_news.py: keep both appended blocks.TST: Cover the tables and summaries of NewsResults
Add tests of the paths of statespace/news.py that the TSA test suite did
not reach, each checked against an independent value:
weights, revisions, news and impacts of revision_details_by_impact
(with all revisions detailed) and details_by_impact, and the estimates
of the impacts table; with two updates, the details table of each
update date;
revision and update impacts, and these add up to the change in the
estimates, with detailed and with grouped revisions;
the results) and tolerance (set on the results) select the rows of
every details table and of the impacts table;
every cell of the tables against the DataFrames they show (the AR(1)
closed forms for the univariate details), with and without sparsifying,
with each groupby (and its underscore spelling), the impact and update
date and variable selections, multiple tables, the univariate defaults,
show_revisions_columns, the weights shown as 1.0 and 0, equal values of
different variables (not blanked), and the errors for an invalid
groupby;
states) and its tables against the individual summary methods with
every argument (including the revision date and revised variable of
the details of revisions), for univariate and multivariate models;
impacts of the revisions through the first state are those of the
first variable;
matching impacts), and get_impacts with a groupby of the updated
variables.
Two bugs of NewsResults, not fixed here, shape the tests: the univariate
summaries are tested with a one-letter series name (k_endog is the length
of the name of the series of a univariate model), and
test_get_impacts_groupby ignores the two FutureWarnings that pandas < 3
raises in get_impacts with a groupby (stack without future_stack).
Coverage of news.py by the TSA tests goes from 85.6% to 97.0% of the
lines and from 63.9% to 98.3% of the branches.
DOC: Correct the docstrings of NewsResults
Fix the docstrings of statespace/news.py where they disagree with the
code. No code changes.
groupbygroups the updated (or revised) variablesseparately for each update date, for example with a dict or a function
of the variable names; it is not applied to the combined details table
and cannot group the update dates, which the docstring gave as its
example (that raises a KeyError). The index of the result has the
levels
update dateandupdated variable(or the groups).both get_details and get_impacts return an empty table if both include
flags are False.
newscolumn; the columns of data_updates,data_revisions, details_by_impact and revision_details_by_impact and
the index levels of details_by_update and revision_details_by_update
are listed in their actual order; the details tables and impacts only
include the rows above
toleranceand of the selectedimpacted_variable.updated_variableare the variables that generatedthe news, not those affected by it, and with
source="revisions",update_date,updated_variableandgroupbyrefer to the revisiondates and revised variables.
with
include_revisions_tables=True(default False) and only if thedata were revised, and
revision_dateandrevised_variableapply tothe details tables of revisions.
KalmanSmoother.news).
BUG: Show the impact dates of NewsResults.summary_impacts as text
summary_impacts (and the impacts table of summary) formats the impact
dates and impacted variables as strings and writes them back with a
block assignment (impacts.iloc[:, :2] = ...). pandas converts the strings
back to the dtype of the column, so for a PeriodIndex or a
DatetimeIndex the dates stay dates, and the sparsified (blanked) repeated
dates were shown as "NaT" in every multivariate table grouped by impact
date. For integer dates (data given as a list or an ndarray), pandas 3
raised "TypeError: Invalid value '...' for dtype 'int64'" (a FutureWarning
on pandas 2.x), also for univariate models, so summary of such news raised.
Changes
each column. Series.map exists in every supported pandas version, so the
pandas < 2.1 fallback of the multivariate block (which made the same
block assignment with applymap) is not needed any more.
Not changed
univariate table is a column of str instead of dates, with the same
text. The unreachable fallback around Series.map of the univariate block
is left for a separate pull request.
Tests
DatetimeIndex and integer dates, with and without sparsifying, every
cell of summary_impacts is that of the impacts DataFrame (the repeated
dates blank), and summary shows the same table. On the base, the
multivariate sparsified cases with dates fail, and the integer cases
fail on pandas 3 (warn on pandas 2.3).
BUG: Allow a single impact date and variable in NewsResults.summary_impacts
summary_impacts selects the rows of the impacts table with
impacts.loc[(impact_date, impacted_variable), :]. If both are single
labels, this is a complete key of the MultiIndex, and pandas returns the
row as a Series, so the table code raised "AttributeError: 'Index' object
has no attribute 'remove_unused_levels'", for example for
news.summary_impacts(impact_date="2009Q3", impacted_variable="unemp") or
news.summary(impact_date="2009Q3", impacted_variable="unemp"). Univariate
models whose series has a one-letter name select their variable by
default, so any single impact date raised for them, also a partial date
string such as "2009".
Changes
which is what .loc uses for every key that is not a complete key, so a
single impact date and variable give a table with one row (or the rows
of a partial date string).
Not changed
the table still raises a KeyError (with the label alone as the message
instead of the tuple).
Tests
partial date string, with a single impacted variable of a multivariate
model, and with and without the variable of a univariate model, the
table shows the rows of the impacts DataFrame, summary shows the same
table, and a date without impacts raises a KeyError. All cases fail on
the base.
BUG: Sparsify NewsResults.summary_impacts for every groupby spelling
summary_impacts accepts groupby="impact_date" and "impacted_variable" as
spellings of "impact date" and "impacted variable" (as summary_details
does), but it sparsifies the first column only if groupby is the name of
a column, so with the underscore spellings the repeated impact dates (or
impacted variables) were not blanked. The title joins a single impacted
variable or impact date that was moved out of the table with "on" if
groupby == "date", which no valid groupby is, so it was always "for".
Changes
replaced by spaces) before it is used, so every spelling gives the same
table.
impact date (the default, so for example in the impacts table of every
univariate model) and "Impacts for [impact date = ...]" when grouping by
impacted variable.
Not changed
the title, and the error for an invalid groupby.
Tests
the impacts DataFrame with the first column sparsified, and the title of
a table with a single impacted variable or impact date. The underscore
spellings and the title with "on" fail on the base.
BUG: Allow multiple NewsResults details tables by impact date or variable
summary_details(multiple_tables=True) makes one table for each value of
the groupby key, which it looks up in a dict of the column names that
only has the update (revision) date and variable. With
groupby="impact date" or "impacted variable" it raised a KeyError, and so
did summary(details_groupby="impact date") (or "impacted variable") for
every multivariate model, also with the default include_details_tables
(summary makes the details tables even if it does not show them), and for
univariate models whose series name is longer than one character.
Changes
impact date and the impacted variable, so there is one table for each
impact date or impacted variable.
Not changed
Tests
variable, there is a table for each key, whose cells are those of the
details DataFrame for that key, and summary shows these tables. All
cases fail on the base.
BUG: Apply the univariate defaults of NewsResults to every univariate model
NewsResults set k_endog = len(self.endog_names), and endog_names of a
univariate model is the name of the series (a str), so k_endog was the
length of the name. The documented univariate defaults applied only to
series with a one-letter name. For a series named "infl" (k_endog = 4),
summary showed no details tables by default, include_details_tables=True
gave one details table per update date, summary_details with
multiple_tables=True kept the variable columns, and
summary(details_groupby="impact date") raised a KeyError.
Where they applied, the defaults selected the rows of the tables by the
name of the variable, so for one-letter names summary raised a KeyError
when there were no new observations or no impacts above the tolerance (an
empty table), and with include_revisions_tables=True when all revisions
were grouped (the default revisions_details_start=False); with some
revisions grouped, the "all prior revisions" rows were silently dropped
from the details of the revisions. Fixing k_endog alone would have made
these errors happen for every univariate model.
Changes
the tables: summary_impacts used it only to select the rows (a no-op
otherwise), and summary_details treats it as selected, so that it is
moved to the title of multiple tables.
multiple tables, so the summary of a univariate model without news (or
without impacts above the tolerance) gains no empty table.
Results change for valid input of univariate models whose series name is
longer than one character: summary shows the details tables by default,
as documented, and a single details table for any details_groupby;
summary_details(multiple_tables=True) shows the variable in the title;
k_endog is 1. For one-letter names, the details of the revisions include
the grouped revisions.
Not changed
above.
Tests
details table of the news and of the revisions by default for each
grouping (also a table with a single row), and multiple tables show the
variable in the title.
grouped, and with no impact above the tolerance, summary shows the
expected tables (no empty details tables), and the details of the
revisions include the grouped revisions and sum to the impacts of the
revisions. These cases fail on the base for "y" (and with k_endog fixed
alone, also for "infl").
variable in a column of multiple tables unless it is selected.
instead of "y", which they used because of this bug, and
test_summary_univariate runs with both names.
BUG: Allow NewsResults.summary_impacts of dates without impacts
summary_impacts selected the impact dates and impacted variables given by
impact_date and impacted_variable from the impacts table, which leaves out
the rows whose impacts of news and of revisions are all within the
tolerance. An impact date or impacted variable whose impacts were all
within the tolerance therefore raised a KeyError, although a range of such
dates gives a table without rows. For example, with an AR(1) of infl
whose previous data end in 2009Q2 and news for 2009Q3 (impact dates
2009Q2-2009Q4), summary_impacts(impact_date="2009Q2") raised
"KeyError: '2009Q2'" (the observed 2009Q2 has no impact of the news), and
with tolerance=1e6, so did every impact date and impacted variable.
A list with such a date raised as well, for example
impact_date=["2009Q2", "2009Q3"].
Changes
out, so that such a date or variable selects no rows: the table has only
the header, and a list gives the rows of the other dates. The impacts
property and summary_impacts share the code of the impacts table
(a private _get_impacts).
Not changed
KeyError, and the tables of selections with impacts above the tolerance
are the same.
KeyError; see the next commit.
Tests
above every impact), selecting the date, the variable or both gives a
table with only the header, where the impacts DataFrame has no rows for
them; dates outside the impact dates and unknown variables still raise.
A list with the observed date gives the row of the other date, with the
values of the impacts DataFrame. All cases fail on the base with the
KeyError (pandas 3.0; also checked with pandas 2.3.3).
BUG: Allow NewsResults.summary_details of dates without impacts
summary_details selected the impact dates, impacted variables, update (or
revision) dates and updated (or revised) variables given by its arguments
from details_by_impact (or revision_details_by_impact), which leaves out
the rows whose impact is within the tolerance. As in summary_impacts
(previous commit), a date or variable whose impacts were all within the
tolerance raised a KeyError, and so did summary, which passes impact_date
and impacted_variable to both. For example, with the AR(1) of infl whose
previous data end in 2009Q2 and news for 2009Q3,
summary_details(impact_date="2009Q2") and summary(impact_date="2009Q2")
raised "KeyError: '2009Q2'", and with tolerance=1e6, every selection of
summary_details raised.
Changes
out, so that such a date or variable selects no rows: the details table
has only the header, and a list gives the rows of the other dates.
summary leaves out the details tables without rows, as it does without a
selection. The details_by_impact and revision_details_by_impact
properties and summary_details share the code of the tables (private
_get_details_by_impact and _get_revision_details_by_impact).
Not changed
the tables of selections with impacts above the tolerance are the same.
the news when there are only revisions) still raises a KeyError for a
selected label, so summary(impact_date=...) of news with revisions only
still raises (it builds the details of the news even if they are not
shown). This has a different cause and is left for a separate fix.
Tests
an impact date, impacted variable, update (revision) date or updated
(revised) variable gives the details of news and of revisions with only
the header (the columns of the table without a selection); labels that
are not in the tables still raise.
the header, and a list with it gives the row of the other date, with the
values of details_by_impact.
header and the tables of the news and revisions, without details tables,
for both models.
and 2.3.3).
BUG: Add the missing spaces to the NewsResults groupby error messages
The ValueError of summary_impacts for an invalid groupby ended with
'"impacted variable".Got "..."', and that of summary_details with
'"impact date",or "impacted variable"': the strings joined by implicit
concatenation missed a space.
Changes
'... "impact date", or "impacted variable". Got "..."'.
Not changed
Tests
The message of each method for an invalid groupby equals the full text
(fails on the previous commit).
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 coverage audit of the state space models, writing the fix and its tests, and checking them (tests failing on the base, 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