Conditional functions.
Classes:
- IfElse
Implements an If-Else conditional statement.
A node that takes as input a numpy array of values, parameters for a conditional statement, one array of values to be returned if the condition is true, and one array of values to be returned if the condition is false. The condition is evaluated element-wise. All arrays must have the same shape.
Comparison function may be greater that (gt), greater than or equal (ge), less than (lt), less than or equal (le), equal (eq), or not equal (ne).
Examples:
>>> cond_vals = np.array([0, 1, 0])
>>> if_vals = np.array([1, 1, 1])
>>> else_vals = np.array([-1, -1, -1])
>>> IfElse("if_else", "cond_vals", "if_vals", "else_vals")(cond_vals)
array([-1, 1, -1])
>>> cond_vals = np.array([[0, .9, 0], [.8, .1, .5]])
>>> if_vals = np.array([[1, 1, 1], [1, 1, 1]])
>>> else_vals = np.array([[-1, -1, -1], [-1, -1, -1]])
>>> IfElse("if_else", "cond_vals", "if_vals", "else_vals",
... threshold=.5, comparison="lt")(cond_vals)
array([[1, -1, 1],
[-1, 1, -1]])
Args:
alias
: The alias of the node.input_cond_vals
: The alias of the input node for values used to evaluate the condition.input_if_vals
: The alias of the input node for values to be returned if the condition is true.input_else_vals
: The alias of the input node for values to be returned if the condition is false.threshold
: The threshold to use for the condition. Default is 1.comparison
: The comparison operator to use. One of 'ge' (default), 'le', 'gt', 'lt', 'eq', or 'ne'.
__init__(
alias: str,
input_cond_vals: str,
input_if_vals: str,
input_else_vals: str,
threshold: float = 1,
comparison: str = 'ge'
)
Initialize IfElse node.
run(cond_vals, if_vals, else_vals)
Run the node.
Args:
cond_vals
: The values to use to evaluate the condition.if_vals
: The values to return if the condition is true.else_vals
: The values to return if the condition is false.
This file was automatically generated via lazydocs.