Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #48 from Open-EO/update-clip
Browse files Browse the repository at this point in the history
Update clip to handle nodata values
  • Loading branch information
ValentinaHutter authored Aug 31, 2021
2 parents 8b64dc2 + 4eae837 commit 2305438
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/openeo_processes/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 3 additions & 0 deletions tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """
Expand Down

0 comments on commit 2305438

Please sign in to comment.