Use a loop's variables in any operator inside the loop: type $i in a property #8643
aglinxinyuan
started this conversation in
Ideas
Replies: 2 comments 1 reply
In general, can you try to include a bit more detail about this topic, especially what the design is? Currently only the user experience is described. |
1 reply
|
For 3, a good use case is the "k" in the k-means algorithm. We want the user of the algorithm to access the k value, which can be passed as a state variable from the LoopStart operator. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pull requests (reviewed and merged separately):
$iin operator properties$iself.statein UDFs$iin their propertiesHow it works
Declare the variable in Loop Start, type
$min_starsinto a property of any operator in the loop, and run. Each iteration uses its own value, and the operator's code does not change.Design
A reference such as
$iis a placeholder that is filled in when the loop runs:$igets a typed placeholder (0, 0.0 or false), and the reference is recorded beside the operator. A text property keeps$ias its text.$AAPLstays plain text, and a numeric$iis an error.self.statebefore it callsprocess_state, so every callback can read the variables.Only Loop Start's initialization and Loop End's update change the variables, so they stay fixed within an iteration. Every copy of the state that an operator receives therefore agrees, and filling each placeholder once per iteration is enough.
Screenshots
A run of
Text Input (1..6) -> Loop Start (i = 0) -> Limit ($i) -> Loop End: iterationiletsirows through, so Loop End collects 0 + 1 + ... + 5 = 15 rows.In a Python UDF
Not supported yet
Operators that also take input from outside the loop, properties that name a column, a numeric or boolean property that a Python-generated operator checks or computes with before it runs, a literal
$...text inside a loop, operators in an inner loop of nested loops, and the Form View.Feedback wanted
Is
$namethe right syntax, and how should a literal$be written inside a loop?How should a user refer to a loop variable in place of a true/false checkbox, such as the one below? A checkbox cannot hold
$name, so inside a loop it currently becomes a text box that takestrue,falseor$name. Would a checkbox with a "use a loop variable" toggle be better?What are good use cases for loop variables? For example: sweeping a model's hyperparameter, a filter threshold, or a chart setting across iterations.
All reactions