From b0bb86efe0df34e9196e9927875bea8434357b14 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Sun, 22 Oct 2023 02:49:38 +0200 Subject: [PATCH] Remove unnecessary for loop when using get_axis_num (#8356) --- xarray/core/variable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index 4ad723325d3..9601ad49d05 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -2162,7 +2162,7 @@ def rolling_window( raise ValueError( f"Expected {name}={arg!r} to be a scalar like 'dim'." ) - dim = [dim] + dim = (dim,) # dim is now a list nroll = len(dim) @@ -2193,7 +2193,7 @@ def rolling_window( pads[d] = (win - 1, 0) padded = var.pad(pads, mode="constant", constant_values=fill_value) - axis = tuple(self.get_axis_num(d) for d in dim) + axis = self.get_axis_num(dim) new_dims = self.dims + tuple(window_dim) return Variable( new_dims,