You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
times that are equally spaced should be equivalent to not passing times at all —
that invariant is asserted directly by test_ewma_with_times_equal_spacing. It holds
for three of the four adjust × ignore_na combinations, but breaks for adjust=False, ignore_na=False once the data contains NaN:
With ignore_na=False a NaN gap pushes Δ above 1, so the two disagree.
test_ewma_with_times_equal_spacing does not catch this because it is not
parametrized over adjust, and GH-59142's own test_ewma_with_times_variable_spacing
uses np.arange(3) with no NaN, so the interaction with NaN was never covered.
Worth noting: this divergence is newly visible as of GH-66521. Before that fix both
spellings agreed — but they agreed on the wrong value, because the com == 1 special
case intended for the times path was leaking into the no-times path (GH-31178). GH-66521 deliberately fixed only the no-times path and left times exactly as 3.0
shipped it, which is what surfaces the inconsistency.
Expected Behavior
Undecided, and that is really the question here — the two candidate generalizations
are both defensible, so this needs a call on intended semantics:
Make times normalized across NaN gaps, restoring the equal-spacing
invariant and making ewm NaN handling is wrong : simple example #31178's example return 3.666667 in both spellings. Note
this cannot be done by simply switching the times path to the normalized form: test_ewma_with_times_variable_spacing value-pins the convex form for adjust=False (0.2376251864...; the normalized form gives 0.39608). It would
require distinguishing decay from elapsed interval from decay accumulated across
skipped NaN rows.
Declare the convex form correct for times and document that ignore_na=False weights NaN gaps differently once times is supplied,
accepting that equally spaced times is not equivalent to no times in this one
combination.
Pandas version checks
Reproducible Example
Issue Description
timesthat are equally spaced should be equivalent to not passingtimesat all —that invariant is asserted directly by
test_ewma_with_times_equal_spacing. It holdsfor three of the four
adjust×ignore_nacombinations, but breaks foradjust=False, ignore_na=Falseonce the data containsNaN:The two paths generalize
adjust=Falseto a gap ofΔdifferently. They agree atΔ = 1and diverge otherwise:times— normalized, matching the recursion documented forignore_na:y_t = ((1-α)^Δ · y_u + α · x_t) / ((1-α)^Δ + α)times— convex, added in ENH: Allow adjust=False when times is provided #59142 to support irregular intervals:y_t = (1-α)^Δ · y_u + (1 - (1-α)^Δ) · x_tWith
ignore_na=FalseaNaNgap pushesΔabove 1, so the two disagree.test_ewma_with_times_equal_spacingdoes not catch this because it is notparametrized over
adjust, and GH-59142's owntest_ewma_with_times_variable_spacinguses
np.arange(3)with noNaN, so the interaction withNaNwas never covered.Worth noting: this divergence is newly visible as of GH-66521. Before that fix both
spellings agreed — but they agreed on the wrong value, because the
com == 1specialcase intended for the
timespath was leaking into the no-timespath (GH-31178).GH-66521 deliberately fixed only the no-
timespath and lefttimesexactly as 3.0shipped it, which is what surfaces the inconsistency.
Expected Behavior
Undecided, and that is really the question here — the two candidate generalizations
are both defensible, so this needs a call on intended semantics:
timesnormalized acrossNaNgaps, restoring the equal-spacinginvariant and making ewm NaN handling is wrong : simple example #31178's example return
3.666667in both spellings. Notethis cannot be done by simply switching the
timespath to the normalized form:test_ewma_with_times_variable_spacingvalue-pins the convex form foradjust=False(0.2376251864...; the normalized form gives0.39608). It wouldrequire distinguishing decay from elapsed interval from decay accumulated across
skipped
NaNrows.timesand document thatignore_na=FalseweightsNaNgaps differently oncetimesis supplied,accepting that equally spaced
timesis not equivalent to notimesin this onecombination.
Related: GH-54328 (the request GH-59142 implemented) and GH-40098.
Installed Versions
Details
Reproduces on main (3.1.0.dev0). The
timesside is unchanged since 3.0.0; thedivergence between the two spellings appears with GH-66521.