Skip to content
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

Restructure storage of parameters and widgets in ParameterPanel #102

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

agoscinski
Copy link
Collaborator

@agoscinski agoscinski commented Dec 19, 2024

Introduce param_to_widget_map to access the widgets in form of a dict for more convenient handling.

To more robustly set parameter values the setter has been replaced by the update_params method. The setter introduced behavior that is unintuitive for python as it behaves like an update function while using assign syntax.

Alternatively a design implementing methods __{get,set}item__, values and keys was considered, but keys was clashing with the trait variable of Widget which would have required a different naming. This would have been more confusing.

code_ex.params # returns parameter_panel
code_ex.params['x'] = 5 # works, updates the panel
code_ex.params['x']
code_ex.params.values() # works
code_ex.params.params_keys() # cannot be keys because it is already used by Widget

📚 Documentation preview 📚: https://scicode-widgets--102.org.readthedocs.build/en/102/

@agoscinski agoscinski force-pushed the parameter-panel-code-api branch 2 times, most recently from bf3243c to 8dd293d Compare December 19, 2024 08:59
Introduce `param_to_widget_map` to access the widgets in form of a dict
for more convenient handling.

To more robustly set parameter values the setter has been replaced by
the `update_params` method. The setter introduced behavior that is
unintuitive for python as it behaves like an update function while using
assign syntax.

Alternatively a design implementing methods `__{get,set}item__`,
`values` and `keys` was considered, but `keys` was clashing with the
trait variable of `Widget` which would have required a different naming.
This would have been more confusing.

```python
code_ex.params # returns parameter_panel
code_ex.params['x'] = 5 # works, updates the panel
code_ex.params['x']
code_ex.params.values() # works
code_ex.params.params_keys() # cannot be keys because it is already used by Widget
```
@agoscinski agoscinski force-pushed the parameter-panel-code-api branch from 8dd293d to 9d8681d Compare December 19, 2024 09:00
@agoscinski agoscinski merged commit 76ce8c6 into main Dec 19, 2024
2 of 3 checks passed
@agoscinski agoscinski deleted the parameter-panel-code-api branch December 19, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant