Skip to content

← control_flow package

Switch

Switch expression for conditional control.

This node is used as follows: a value is wired into test_value, and then that value is compared with the values set in the match 1 through math 10 parameters, in 1-10 order. If a match is found, the corresponding branch is executed and its value returned and remaining conditions are not evaluated. If no conditions match, then the branch wired into else_branch is executed and its value (the output of its execution) is returned through the result port, which can be wired into a downstream node for processing. If nothing was wired into the condition port that was selected for execution, then the result outputs None. The Switch and ConditionSwitch nodes differ in their use in that the Switch node is used to control the execution of an upstream branch and return its result downstream, whereas the ConditionSwitch is used to control the execution of downstream nodes (usually by wiring it into the Passthrough node to "turn off" execution at a given point in the pipeline). Version 1.0.0

Ports/Properties

test_value

Value to test.

  • verbose name: Test Value
  • default value: None
  • port type: DataPort
  • value type: object (can be None)
  • data direction: IN

condition1

Test value for branch 1.

  • verbose name: Branch 1 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch1

Branch 1.

  • verbose name: Branch1
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition2

Test value for branch 2.

  • verbose name: Branch 2 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch2

Branch 2.

  • verbose name: Branch2
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition3

Test value for branch 3.

  • verbose name: Branch 3 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch3

Branch 3.

  • verbose name: Branch3
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition4

Test value for branch 4.

  • verbose name: Branch 4 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch4

Branch 4.

  • verbose name: Branch4
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition5

Test value for branch 5.

  • verbose name: Branch 5 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch5

Branch 5.

  • verbose name: Branch5
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition6

Test value for branch 6.

  • verbose name: Branch 6 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch6

Branch 6.

  • verbose name: Branch6
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition7

Test value for branch 7.

  • verbose name: Branch 7 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch7

Branch 7.

  • verbose name: Branch7
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition8

Test value for branch 8.

  • verbose name: Branch 8 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch8

Branch 8.

  • verbose name: Branch8
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition9

Test value for branch 9.

  • verbose name: Branch 9 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch9

Branch 9.

  • verbose name: Branch9
  • default value: None
  • port type: GraphPort
  • value type: Graph

condition10

Test value for branch 10.

  • verbose name: Branch 10 Match
  • default value: None
  • port type: Port
  • value type: object (can be None)

branch10

Branch 10.

  • verbose name: Branch10
  • default value: None
  • port type: GraphPort
  • value type: Graph

else_branch

Else branch (no match).

  • verbose name: Else Branch
  • default value: None
  • port type: GraphPort
  • value type: Graph

result

Result of the branch that was evaluated.

  • verbose name: Result
  • default value: None
  • port type: DataPort
  • value type: object (can be None)
  • data direction: OUT

emit_resets

Emit signal reset notifications when the condition changes. This can be used if the Switch node controls codepaths through which signals flow and where downstream nodes should reset themselves upon a change of the condition. However, note that, if the condition is systematically changing between training and test mode, this can lead to unexpected behavior: namely, if a Switch in a machine-learning pipeline is driven by an is_training flag, it will cause a reset when the training flag changes, which leads to a reset of trainable state downstream of the switch on the test set (unless the nodes are marked as do not reset model), which then causes retraining on the test set, which is likely a bug (that can give spuriously better results). For this reason, this flag is turned off by default, but it may be enabled if needed.

  • verbose name: Emit State Resets
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)