Repository navigation
Keep SpaceRenderer setup kwargs when SolaraViz resets - #3951
Merged
Merged
Conversation
|
Performance benchmarks:
|
copy_renderer still copied space_kwargs and agent_kwargs, but SpaceRenderer stores them as draw_space_kwargs and draw_agent_kwargs. The old names don't exist anymore, so pressing Reset silently dropped everything passed to setup_structure() and setup_agents(). Copy the right attributes, and copy the dicts so the old and new renderer don't share them. Add a regression test. Fixes mesa#3948
AshNicolus
force-pushed
the
fix/copy-renderer-draw-kwargs
branch
from
November 6, 2026 10:12
1a5032f to
83c1295
Compare
quaquel
approved these changes
Nov 7, 2026
EwoutH
pushed a commit
that referenced
this pull request
Nov 22, 2026
copy_renderer still copied space_kwargs and agent_kwargs, but SpaceRenderer stores them as draw_space_kwargs and draw_agent_kwargs. The old names don't exist anymore, so pressing Reset silently dropped everything passed to setup_structure() and setup_agents(). Copy the right attributes, and copy the dicts so the old and new renderer don't share them. Add a regression test. Fixes #3948 (cherry picked from commit b687223)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-PR Checklist
Summary
When you press Reset in SolaraViz, the space loses its styling. Anything you passed to
setup_structure()orsetup_agents()(likegrid_colororcmap) is gone after the reset. This PR makes Reset keep those settings.Bug / Issue
Fixes #3948
On Reset, SolaraViz builds a fresh renderer with
copy_renderer(). That function copies a list of attributes from the old renderer, but two names on that list are outdated:flowchart LR A[Reset clicked] --> B[copy_renderer] B --> C{"copy 'space_kwargs'<br/>and 'agent_kwargs'"} C -->|these names don't exist anymore| D[nothing copied] D --> E[space redrawn with defaults]SpaceRendererstores these asdraw_space_kwargsanddraw_agent_kwargs. Sincecopy_rendererusesgetattr(renderer, attr, None), the old names just returnedNoneand were skipped without any error.Implementation
draw_space_kwargsanddraw_agent_kwargs, incopy_renderer.What you get after a reset:
Testing
test_copy_renderer_keeps_setup_kwargsintests/visualization/test_solara_viz.py. It fails onmain(the copied kwargs come back as{}) and passes with this change.pytest tests/ -Werror(876 passed).pre-commit(ruff, pyupgrade, codespell) passes on the changed files.Additional Notes
copy_rendererhad no tests before, so this also gives it some basic coverage.