From 602d04315928dfd535645810bf05fe52662efe0e Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 17 Sep 2023 01:27:05 -0700 Subject: [PATCH] Adjust after #8183 --- xarray/core/rolling_exp.py | 45 ++++++++------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/xarray/core/rolling_exp.py b/xarray/core/rolling_exp.py index a83ecc542ec..de0fd904356 100644 --- a/xarray/core/rolling_exp.py +++ b/xarray/core/rolling_exp.py @@ -131,42 +131,15 @@ def mean(self, keep_attrs: bool | None = None) -> T_DataWithCoords: dim_order = self.obj.dims - from xarray.core.dataset import Dataset - - if isinstance(self.obj, Dataset): - new_ds = self.obj.copy() - if not keep_attrs: - new_ds.attrs = {} - for name, var in self.obj.variables.items(): - if self.dim in self.obj[name].dims: - new_ds[name] = apply_ufunc( - move_exp_nanmean, - var, - input_core_dims=[[self.dim]], - kwargs=dict(alpha=self.alpha, axis=-1), - output_core_dims=[[self.dim]], - # I'm not sure whether this line should be here (can look later, - # docs aren't _that_ clear vs. `input_core_dims`, or I'm being - # slow at understanding them.) - exclude_dims={self.dim}, - keep_attrs=keep_attrs, - ) - # Currently we test for attrs being removed on all arrays, even those - # without the dim, not sure if we should be doing this or not (we can - # indent a line and then only remove attrs on arrays we compute on) - if not keep_attrs: - new_ds[name].attrs = {} - return new_ds.transpose(*dim_order) - else: - return apply_ufunc( - move_exp_nanmean, - self.obj, - input_core_dims=[[self.dim]], - kwargs=dict(alpha=self.alpha, axis=-1), - output_core_dims=[[self.dim]], - exclude_dims={self.dim}, - keep_attrs=keep_attrs, - ).transpose(*dim_order) + return apply_ufunc( + move_exp_nanmean, + self.obj, + input_core_dims=[[self.dim]], + kwargs=dict(alpha=self.alpha, axis=-1), + output_core_dims=[[self.dim]], + exclude_dims={self.dim}, + keep_attrs=keep_attrs, + ).transpose(*dim_order) def sum(self, keep_attrs: bool | None = None) -> T_DataWithCoords: """