copapy.iif#
- copapy.iif(expression, true_result, false_result)#
Inline if-else operation. Returns true_result if expression is non-zero, else returns false_result.
- Overloads:
expression (
value[Any]), true_result (value[int] |int), false_result (value[int] |int) →value[int]expression (
value[Any]), true_result (value[float] |float), false_result (value[float] |float) →value[float]expression (
float|int), true_result (TNum), false_result (TNum) →TNumexpression (
float|int), true_result (TNum|value[TNum]), false_result (value[TNum]) →value[TNum]expression (
float|int), true_result (value[TNum]), false_result (TNum|value[TNum]) →value[TNum]expression (
float|int|value[Any]), true_result (TNum|value[TNum]), false_result (TNum|value[TNum]) →value[TNum] |TNumexpression (
float|int|value[Any]), true_result (TContainer), false_result (Any) →TContainerexpression (
float|int|value[Any]), true_result (Any), false_result (TContainer) →TContainer
Both results are computed if expression is not known at trace time. The selection is done without a branching. The result is exact and inf or nan in the result that is not selected have no effect.
Vectors, tensors and arrays as results are selected as a whole by the scalar expression. They are blended by multiplications with 1 and 0 (array stencils for arrays and packed vectors or tensors): inf or nan in an element of the result that is not selected gives nan.
- Parameters:
expression (
Any) – The condition to evaluate: a number or copapy value.true_result (
Any) – The result if expression is non-zero.false_result (
Any) – The result if expression is zero.
- Returns:
The selected result based on the evaluation of expression.