inaos / iron-array

2 stars 0 forks source link

Support for user params in UDFs #491

Closed FrancescAlted closed 2 years ago

FrancescAlted commented 2 years ago

User Defined Functions accept parameters for output and input data streams, but not for other parameters that the user might want to use inside the UDF. For example:

@jit()
def udf_iarray(out: Array(float32, 3),
               p1: Array(float32, 3),
               p2: Array(float32, 3),
               p3: Array(float32, 3),
               myvar1: int,
               myvar2: int) -> int:

    if myvar1 > 10:
        do_something()
    if myvar2 < 0:
        do_something_else()
    return 0

The compilation call can be something like:

ia.expr_from_udf(udf_iarray, [precip1, precip2, precip3], [myvar1, myvar2])
jdavid commented 2 years ago

This was done in https://github.com/inaos/iron-array/pull/498 and https://github.com/inaos/iron-array-python/pull/139