Skip to content

Extend rolling_exp to support pd.Timedelta objects with window halflife #10237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: adjust rolling_exp test to avoid re-assigning pandas_array for …
…compatibility with pandas < 2.2.0

pandas ewm can work with non-ns resolution from >= 2.2.0. Here we just test that this PR rolling_exp can work with non-ns resolution.
  • Loading branch information
abiasiol committed Apr 20, 2025
commit e2c41e03f47ac409e206a5f111c7b75ae4e20b4b
7 changes: 3 additions & 4 deletions xarray/tests/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,9 @@ def test_rolling_exp_mean_pandas_halflife(self, da, window) -> None:
# test with different time units (ms -> s)
da["time"] = da.get_index("time").astype("datetime64[s]")
result = da.rolling_exp(window_type=window_type, **{dim: window}).mean()
pandas_array = da.to_pandas()
expected = xr.DataArray(
pandas_array.ewm(**{window_type: window}, times=pandas_array.index).mean()
).transpose(*da.dims)

# pandas < 2.2.0 does not support non-ns resolution for ewm
# so let's not re-assign pandas_array
assert_allclose(expected.variable, result.variable)

@pytest.mark.parametrize("backend", ["numpy"], indirect=True)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy