Skip to content

Commit bc6142c

Browse files
committed
Address rolling window review comments
1 parent 18b92fa commit bc6142c

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

lib/iris/cube.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,9 +5243,7 @@ def rolling_window(
52435243
# window and the bounds are the first and last points in the
52445244
# window as with numeric coordinates.
52455245
new_points = np.apply_along_axis(lambda x: "|".join(x), -1, new_bounds)
5246-
# Index with a list rather than a tuple: a tuple is interpreted
5247-
# as a multidimensional index by Dask, so lazy coordinates would
5248-
# otherwise fail here (see #6480).
5246+
# Use list indexing so Dask selects columns, not dimensions.
52495247
new_bounds = new_bounds[:, [0, -1]]
52505248
else:
52515249
# Take the first and last element of the rolled window (i.e.

lib/iris/tests/unit/cube/test_Cube.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,17 +1087,16 @@ def test_lazy(self):
10871087
_shared_utils.assert_masked_array_equal(expected_result, res_cube.data)
10881088

10891089
def test_lazy_aux_coord(self):
1090-
# A lazy aux-coord paralleling the rolled dimension must not cause a
1091-
# failure, and should give the same result as a real one, staying lazy
10921090
# (see #6480).
1091+
window = 2
10931092
self.cube.add_aux_coord(AuxCoord(da.arange(6), long_name="lazy_extra"), 0)
1094-
res_cube = self.cube.rolling_window("val", iris.analysis.MEAN, 3)
1093+
res_cube = self.cube.rolling_window("val", iris.analysis.MEAN, window, mdtol=0)
10951094
result_coord = res_cube.coord("lazy_extra")
10961095
assert result_coord.has_lazy_points()
10971096
assert result_coord.has_lazy_bounds()
10981097
expected = AuxCoord(
1099-
np.array([1.0, 2.0, 3.0, 4.0]),
1100-
bounds=np.array([[0, 2], [1, 3], [2, 4], [3, 5]]),
1098+
np.array([0.5, 1.5, 2.5, 3.5, 4.5]),
1099+
bounds=np.array([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]),
11011100
long_name="lazy_extra",
11021101
)
11031102
assert result_coord == expected

0 commit comments

Comments
 (0)