Skip to content

Commit 29c44fc

Browse files
committed
document xarray DataArray based UDF signature
1 parent 7b85683 commit 29c44fc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

openeo/udf/udf_signatures.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
# Note: this module was initially developed under the ``openeo-udf`` project (https://github.com/Open-EO/openeo-udf)
88

9+
from deprecated import deprecated
910
import xarray
1011
from pandas import Series
1112

@@ -33,11 +34,13 @@ def apply_timeseries(series: Series, context: dict) -> Series:
3334
# TODO: do we need geospatial coordinates for the series?
3435
return series
3536

36-
37+
@deprecated
3738
def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
3839
"""
3940
Map a :py:class:`XarrayDataCube` to another :py:class:`XarrayDataCube`.
4041
42+
Deprecated: use the signature with xarray.DataArray instead.
43+
4144
Depending on the context in which this function is used, the :py:class:`XarrayDataCube` dimensions
4245
have to be retained or can be chained.
4346
For instance, in the context of a reducing operation along a dimension,
@@ -50,6 +53,22 @@ def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
5053
"""
5154
return cube
5255

56+
def apply_datacube(cube: xarray.DataArray, context: dict) -> xarray.DataArray:
57+
"""
58+
Map a :py:class:`xarray.DataArray` to another :py:class:`xarray.DataArray`.
59+
60+
Depending on the context in which this function is used, the :py:class:`xarray.DataArray` dimensions
61+
have to be retained or can be chained.
62+
For instance, in the context of a reducing operation along a dimension,
63+
that dimension will have to be reduced to a single value.
64+
In the context of a 1 to 1 mapping operation, all dimensions have to be retained.
65+
66+
:param cube: input data array
67+
:param context: A dictionary containing user context.
68+
:return: output data array
69+
"""
70+
return cube
71+
5372

5473
def apply_udf_data(data: UdfData):
5574
"""

0 commit comments

Comments
 (0)