Skip to content

Commit

Permalink
Add test and whatsnew entry
Browse files Browse the repository at this point in the history
  • Loading branch information
bouweandela committed Feb 23, 2024
1 parent bb2ec46 commit 9a8b8d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ This document explains the changes made to Iris for this release
🚀 Performance Enhancements
===========================

#. N/A
#. `@bouweandela`_ made :func:`iris.util.rolling_window` work with lazy arrays.
(:pull:`5775`)


🔥 Deprecations
Expand Down
7 changes: 7 additions & 0 deletions lib/iris/tests/unit/util/test_rolling_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# importing anything else
import iris.tests as tests # isort:skip

import dask.array as da
import numpy as np
import numpy.ma as ma

Expand Down Expand Up @@ -35,6 +36,12 @@ def test_2d(self):
result = rolling_window(a, window=3, axis=1)
self.assertArrayEqual(result, expected_result)

def test_3d_lazy(self):
a = da.arange(2 * 3 * 4).reshape((2, 3, 4))
expected_result = np.arange(2 * 3 * 4).reshape((1, 2, 3, 4))
result = rolling_window(a, window=2, axis=0).compute()
self.assertArrayEqual(result, expected_result)

def test_1d_masked(self):
# 1-d masked array input
a = ma.array([0, 1, 2, 3, 4], mask=[0, 0, 1, 0, 0], dtype=np.int32)
Expand Down

0 comments on commit 9a8b8d9

Please sign in to comment.