Skip to content

Commit

Permalink
JupyterViz: Automatically deduce display name from model class
Browse files Browse the repository at this point in the history
  • Loading branch information
rht authored and Corvince committed Jan 18, 2024
1 parent 877d552 commit 29ff9fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mesa/experimental/jupyter_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def JupyterViz(
model_class,
model_params,
measures=None,
name="Mesa Model",
name=None,
agent_portrayal=None,
space_drawer="default",
play_interval=150,
Expand All @@ -35,6 +35,9 @@ def JupyterViz(
specify `space_drawer=False`
play_interval: play interval (default: 150)
"""
if name is None:
name = model_class.__name__

current_step = solara.use_reactive(0)

# 1. Set up model parameters
Expand Down
1 change: 1 addition & 0 deletions tests/test_jupyter_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class TestJupyterViz(unittest.TestCase):
@patch("mesa.experimental.components.matplotlib.SpaceMatplotlib")
def test_call_space_drawer(self, mock_space_matplotlib):
mock_model_class = Mock()
mock_model_class.__name__ = "MockModelClass"
agent_portrayal = {
"Shape": "circle",
"color": "gray",
Expand Down

0 comments on commit 29ff9fc

Please sign in to comment.