Skip to content

Commit

Permalink
add array_interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaHutter committed Sep 18, 2024
1 parent e7fc372 commit 4de6d18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openeo_processes_dask/process_implementations/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def array_apply(


def array_interpolate_linear(data: ArrayLike):
if isinstance(data, list):
data = np.array(data)
x = np.arange(len(data))
valid = np.isfinite(data)
if len(x[valid]) < 2:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ def test_array_interpolate_linear(data, expected):
expected,
equal_nan=True,
)
assert np.array_equal(
array_interpolate_linear(np.array(data)),
expected,
equal_nan=True,
)
assert np.array_equal(
array_interpolate_linear(da.from_array(np.array(data))),
expected,
equal_nan=True,
)


def test_first():
Expand Down

0 comments on commit 4de6d18

Please sign in to comment.