-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cell grouping for conditional cell set execution #3587
Comments
Im not sure I follow completely. Are you able to do this today? If so, can you share what part is unsystematic and makes navigation difficult? Breaking into re-usable functions sounds like the right approach. |
Sorry about that! Here is simplified example that hopefully makes it clearer. # Cell 1
dropdown = mo.ui.dropdown(
options=["fuit", "vegetable", "meat"], label="choose one"
)
dropdown
#Cell 2
selected_food_group = dropdown.value
#Cell 3
mo.md("## Fruit Cell Set")
#Cell 4
if selected_food_group=="fruit":
mo.output.append(mo.md("Yay! You like fruits"))
fruit_dropdown = mo.ui.dropdown(
options=["apple", "banana", "mango"], value="apple", label="choose one"
)
mo.output.append(fruit_dropdown)
#Cell 5
if selected_food_group=="fruit" and fruit_dropdown=="apple":
ask_apple_fruit = mo.ui.text(value="", label="Do you think apple a day keeps doctor away?")
mo.output.append(ask_apple_fruit)
#Cell 6
if selected_food_group=="fruit" and fruit_dropdown=="apple" and ask_apple_fruit.value:
mo.output.append(mo.md(ask_apple_fruit.value+" to keeping the doctor away"))
#Cell 7
mo.md("Vegetable Cell Set")
"""
multiple cells here all that have the conditional selected_food_group=="vegetable"
"""
#Cell 10
mo.md("Meat Cell Set")
"""
multiple cells here all that have the conditional selected_food_group=="meat"
""" I will love to be able to do something like this # Cell 1
dropdown = mo.ui.dropdown(
options=["fuit", "vegetable", "meat"], label="choose one"
)
dropdown
#Cell 2
selected_food_group = dropdown.value
#Cell Group 1 (conditional of selected_food_group=="fruit")
#Cell Group 1 - Cell 1 (original cell 3)
mo.md("## Fruit Cell Set")
#Cell Group 1 - Cell 1 (original cell 4)
mo.output.append(mo.md("Yay! You like fruits"))
fruit_dropdown = mo.ui.dropdown(
options=["apple", "banana", "mango"], value="apple", label="choose one"
)
mo.output.append(fruit_dropdown)
#Cell Group 1 - Cell 2 (original cell 5)
if fruit_dropdown=="apple":
ask_apple_fruit = mo.ui.text(value="", label="Do you think apple a day keeps doctor away?")
mo.output.append(ask_apple_fruit)
#Cell Group 1 - Cell 3 (original cell 6)
if ask_apple_fruit.value:
mo.output.append(mo.md(ask_apple_fruit.value+" to keeping the doctor away"))
#Cell Group 2 (conditional of selected_food_group=="vegetable")
#Cell Group 2 - Cell 1 (original cell 7)
mo.md("Vegetable Cell Set")
"""
multiple cells here all that have the conditional selected_food_group=="vegetable" but that doesn't need to be specified for each cell
"""
#Cell Group 3 (conditional of selected_food_group=="meat")
#Cell Group 3 - Cell 1 (original cell 10)
mo.md("Meat Cell Set")
"""
multiple cells here all that have the conditional selected_food_group=="meat" but that doesn't need to be specified for each cell
""" |
I would either split it up into different functions or use Functions
|
Description
For context, I am developing a web application that processes CSV files for statistical analysis. The application follows multiple decision paths depending on data characteristics. For example, if the data is normalized, specific tests are applied; if not, different tests are implemented or user input is requested before proceeding. Each test may generate multiple outputs and might require linked inputs requiring separate cells, which may also reference each other.
I want to be able implement conditional logic for running a groups of cells. Currently, adding conditions to individual cells is unsystematic and makes navigation difficult. While
mo.output.append
enables multiple outputs in one cell, I still run into issues when creating interactive features like user input for selecting columns in a t-test, because they require separate cells.Suggested solution
I have two potential solutions in mind. One involves implementing cell levels using nested functions in Python, which would probably work well. The other approach would be to create a dictionary of functions and call them as needed. Both methods could probably solve this.
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: