-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Add nested select #5791
Add nested select #5791
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #5791 +/- ##
==========================================
+ Coverage 82.68% 84.33% +1.64%
==========================================
Files 291 291
Lines 43071 43346 +275
==========================================
+ Hits 35615 36554 +939
+ Misses 7456 6792 -664
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I believe this is ready to add tests + docs Screen.Recording.2023-11-03.at.7.32.07.PM.mov |
import param
import panel as pn
from panel.widgets.select import *
pn.extension()
options = {
"Ben": ["A", "B"],
"Andrew": {
"temp": [1000, 925, 700, 500, 300],
"vorticity": [500, 300],
},
}
select = NestedSelect(options=options, value=["Ben", "B"])
select I added variable depth support Screen.Recording.2023-11-13.at.7.33.23.AM.mov |
Talked with Philipp. We decided to first rollback variable level nesting, e.g. the following needs more design and should not be allowed for now due to its complexity.
However, given uniform level nesting, we're still debating whether
Should Pros of tuple is that Pros of dict is that it's more explicit and easier to extract the desired value, e.g. |
It seems to me that variable nested levels will come up often, particularly during development. The dict format sounds better to me. Is there any future for dynamic updating with this approach? E.g. instead of a list for a particular entry can you imagine accepting a callable? If so, what would the arguments to the callable be? It's fine to say that more complex cases like that should be handled by nested Parameterized classes; just seeing if they are explicitly out of scope or only not yet considered. |
#5925) * completed tests for nested select. modified code to handle test cases. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed test cases * slight changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Good point! I think it might be out of scope for now, but I imagine it can be a feature enhancement in the near future without breaking changes, when we think of the design a little more... Here's an example: options = {
"Andrew": {
"temp": get_temp_levels,
"windspeed": get_wspd_levels,
},
"Ben": {
"temp": get_temp_levels,
"windspeed": get_wspd_levels,
},
} However, I don't know the input kwargs either. Perhaps it's just the current nested select |
Can we gather some use cases for this? I wasn't able to come up with many good ones. |
During development, if you have to add the same number of items to every sublevel, it seems tricky to try things out... |
Variable nesting refers to the number of levels not the number of items at each level of I understand things correctly. |
That is correct. |
I think we're all saying the same thing, but to be specific, I'm referring to filling out suboptions here for one option but not yet the others:
The question is whether Option 1 is required to have suboptions here once you add them for Option 2. I believe the answer is yes right now, but ideally we wouldn't have to add them at every level if we add them at one level. |
That is correct. Maybe in a future PR when callbacks are supported, we can also have dynamic variable nesting as well. |
I don't think we are (or maybe I'm still misunderstanding) but I think I get your request now. Effectively you want a partial specification to be valid so you don't have to fill out the full tree immediately just to get something working. That's not the same as having a variable number of levels though. I fully agree that what you're saying should be supported but we should make a decision what the behavior of such a partial specification should be, i.e. levels that are not fully specified should either:
|
So to be clear, I think we can and should allow what you described without actually supporting variable levels of nesting as I understand it based on Andrew's initial description of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Have selects depend on each other; worked on this together with @benbarn313.
Screen.Recording.2023-10-31.at.3.27.24.PM.mov
Wondering if we should support this use case, where the nested levels are not even.