-
Notifications
You must be signed in to change notification settings - Fork 928
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 step count display to JupyterViz #1775
Conversation
mesa/experimental/jupyter_viz.py
Outdated
@@ -201,6 +206,12 @@ def on_value_play(change): | |||
playing=playing.value, | |||
on_playing=playing.set, | |||
) | |||
widgets.IntText( |
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.
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.
Instead of widgets.IntText
, maybe try solara.Markdown
instead.
Also, your code means that the widget is created from scratch every time on_value_play
is called. A Solara widget should only be created once, and then is updated.
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.
@rht thanks for the feedback. I didn't see an obvious Solara output field so I followed the other widget examples; I had it set to disabled/read-only, but I agree a real output would be better and I can see now that markdown is feasible.
I've pushed an update that replaces widgets.IntText
with solara.Markdown
and tested locally, it is updating the number when I play through the simulation.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #1775 +/- ##
==========================================
- Coverage 80.29% 80.02% -0.28%
==========================================
Files 15 15
Lines 878 881 +3
Branches 187 188 +1
==========================================
Hits 705 705
- Misses 152 155 +3
Partials 21 21
☔ View full report in Codecov by Sentry. |
Sorry for the late reply. I tested. While the play button updates the step correctly, the step button doesn't. Try removing the mesa/mesa/experimental/jupyter_viz.py Line 126 in cedbefb
|
I haven't tried, but what I meant was solara.Markdown(f"**step:** {viz.model.schedule.steps}, dependencies=[viz.model.schedule.steps]) |
I tried. solara.Markdown(f"**step:** {viz.model.schedule.steps}") worked like magic (no dependency needed). If you can confirm this. |
@rht yes, confirmed. It's great that it's so simple. I just pushed an update to my PR so that this the only line I'm proposing to change now (although it's really your solution, not mine!). |
Content looks good to me. The remaining "concern" is that the viz becomes slightly crowded. @tpike3 do you have concern about information density etc? If you are fine with it, then you can squash and merge this PR. |
Looks Good to Me --- thanks @rlskoeser! This is really good. |
addresses #1773
I don't see any unit tests for the experimental JupyterViz code; I'd be game to add a test if/when there is existing testing infrastructure for this code, but not sure how to go about testing my contribution without examples for the other parts.
I'm not sure if there's any relevant documentation I need to update for this change. I could see if I can generate a new version of the screenshot for the Schelling segregration model displayed on the docs overview page that includes the step count, if that would be helpful/desirable.