forked from Open-EO/openeo-processes-dask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_udf.py
39 lines (31 loc) · 1.08 KB
/
test_udf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import numpy as np
import openeo
import pytest
import xarray as xr
from openeo_processes_dask.process_implementations.udf.udf import run_udf
from tests.general_checks import general_output_checks
from tests.mockdata import create_fake_rastercube
@pytest.mark.parametrize("size", [(6, 5, 4, 4)])
@pytest.mark.parametrize("dtype", [np.float32])
def test_run_udf(temporal_interval, bounding_box, random_raster_data):
input_cube = create_fake_rastercube(
data=random_raster_data,
spatial_extent=bounding_box,
temporal_extent=temporal_interval,
bands=["B02", "B03", "B04", "B08"],
backend="dask",
)
udf = """
from openeo.udf import XarrayDataCube
def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
return cube
"""
output_cube = run_udf(data=input_cube, udf=udf, runtime="Python")
general_output_checks(
input_cube=input_cube,
output_cube=output_cube,
verify_attrs=True,
verify_crs=True,
expected_results=input_cube,
)
xr.testing.assert_equal(output_cube, input_cube)