From 29ff9fc65fb5f6ca15d07355fb7ff3274c33d527 Mon Sep 17 00:00:00 2001 From: rht Date: Thu, 18 Jan 2024 06:33:33 -0500 Subject: [PATCH] JupyterViz: Automatically deduce display name from model class --- mesa/experimental/jupyter_viz.py | 5 ++++- tests/test_jupyter_viz.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mesa/experimental/jupyter_viz.py b/mesa/experimental/jupyter_viz.py index 2e5f066409f..7a586239058 100644 --- a/mesa/experimental/jupyter_viz.py +++ b/mesa/experimental/jupyter_viz.py @@ -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, @@ -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 diff --git a/tests/test_jupyter_viz.py b/tests/test_jupyter_viz.py index 6f88c7d14dc..526e91403c8 100644 --- a/tests/test_jupyter_viz.py +++ b/tests/test_jupyter_viz.py @@ -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",