diff --git a/src/openeo_processes/math.py b/src/openeo_processes/math.py index 6efeffab..545900e7 100644 --- a/src/openeo_processes/math.py +++ b/src/openeo_processes/math.py @@ -3323,10 +3323,7 @@ def exec_xar(x, min, max): The value clipped to the specified range. """ - clip = x.where(x > min, min) - clip = clip.where(x < max, max) - - return clip + return x.clip(min = min, max = max) @staticmethod def exec_da(): diff --git a/tests/test_math.py b/tests/test_math.py index 41727c99..374a6af1 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -323,6 +323,9 @@ def test_clip(self): xr.testing.assert_equal( oeop.clip(self.test_data.xr_data_factor(1, 9), min=1, max=8), self.test_data.xr_data_factor(1, 8)) + xr.testing.assert_equal( + oeop.clip(self.test_data.xr_data_factor(np.nan, 9), min=1, max=8), + self.test_data.xr_data_factor(np.nan, 8)) def test_quantiles(self): """ Tests `quantiles` function. """