from latch import small_task
from latch import create_conditional_section
@small_task
def square(n: float) -> float:
"""
Parameters:
n (float): name of the parameter for the task is derived from the name of the input variable, and
the type is automatically mapped to Types.Integer
Return:
float: The label for the output is automatically assigned and the type is deduced from the annotation
"""
return n * n
@small_task
def double(n: float) -> float:
"""
Parameters:
n (float): name of the parameter for the task is derived from the name of the input variable
and the type is mapped to ``Types.Integer``
Return:
float: The label for the output is auto-assigned and the type is deduced from the annotation
"""
return 2 * n
@workflow
def multiplier(my_input: float) -> float:
result_1 = double(n=my_input)
result_2 = (
create_conditional_section("fractions")
.if_((result_1 < 0.0)).then(double(n=result_1))
.elif_((result_1 > 0.0)).then(square(n=result_1))
.else_().fail("Only nonzero values allowed")
)
result_3 = double(n=result_2)
return result_3