Skip to content

Commit

Permalink
Merge branch 'main' into apply_ufunc
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Sep 17, 2023
2 parents 602d043 + fb9c9b3 commit c12632b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions xarray/core/rolling_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def mean(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
output_core_dims=[[self.dim]],
exclude_dims={self.dim},
keep_attrs=keep_attrs,
on_missing_core_dim="copy",
).transpose(*dim_order)

def sum(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
Expand All @@ -164,6 +165,15 @@ def sum(self, keep_attrs: bool | None = None) -> T_DataWithCoords:
if keep_attrs is None:
keep_attrs = _get_keep_attrs(default=True)

return self.obj.reduce(
move_exp_nansum, dim=self.dim, alpha=self.alpha, keep_attrs=keep_attrs
)
dim_order = self.obj.dims

return apply_ufunc(
move_exp_nansum,
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,
on_missing_core_dim="copy",
).transpose(*dim_order)

0 comments on commit c12632b

Please sign in to comment.