Skip to content

Commit 92e744b

Browse files
Rename JupyterViz to SolaraViz (#2187)
* Rename JupyterViz to SolaraViz * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 01477fc commit 92e744b

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

docs/tutorials/visualization_tutorial.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@
119119
},
120120
"outputs": [],
121121
"source": [
122-
"from mesa.visualization import JupyterViz\n",
122+
"from mesa.visualization import SolaraViz\n",
123123
"\n",
124-
"page = JupyterViz(\n",
124+
"page = SolaraViz(\n",
125125
" BoltzmannWealthModel,\n",
126126
" model_params,\n",
127127
" measures=[\"Gini\"],\n",
@@ -164,7 +164,7 @@
164164
"metadata": {},
165165
"outputs": [],
166166
"source": [
167-
"page = JupyterViz(\n",
167+
"page = SolaraViz(\n",
168168
" BoltzmannWealthModel,\n",
169169
" model_params,\n",
170170
" measures=[\"Gini\"],\n",
@@ -223,7 +223,7 @@
223223
"metadata": {},
224224
"outputs": [],
225225
"source": [
226-
"page = JupyterViz(\n",
226+
"page = SolaraViz(\n",
227227
" BoltzmannWealthModel,\n",
228228
" model_params,\n",
229229
" measures=[\"Gini\", make_histogram],\n",

mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Configure visualization elements and instantiate a server
33
"""
4-
from mesa.visualization import JupyterViz
4+
from mesa.visualization import SolaraViz
55

66
from {{ cookiecutter.snake }}.model import {{ cookiecutter.model }}, {{ cookiecutter.agent }} # noqa
77

@@ -18,7 +18,7 @@ def circle_portrayal_example(agent):
1818

1919
model_params = {"num_agents": 10, "width": 10, "height": 10}
2020

21-
page = JupyterViz(
21+
page = SolaraViz(
2222
{{cookiecutter.model}},
2323
model_params,
2424
measures=["num_agents"],

mesa/visualization/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .jupyter_viz import JupyterViz, Slider, make_text
1+
from .jupyter_viz import JupyterViz, Slider, SolaraViz, make_text
22

3-
__all__ = ["JupyterViz", "make_text", "Slider"]
3+
__all__ = ["JupyterViz", "make_text", "Slider", "SolaraViz"]

mesa/visualization/jupyter_viz.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Mesa models, allowing users to watch models run step-by-step and interact with model parameters.
66
77
Key features:
8-
- JupyterViz: Main component for creating visualizations, supporting grid displays and plots
8+
- SolaraViz: Main component for creating visualizations, supporting grid displays and plots
99
- ModelController: Handles model execution controls (step, play, pause, reset)
1010
- UserInputs: Generates UI elements for adjusting model parameters
1111
- Card: Renders individual visualization elements (space, measures)
@@ -17,7 +17,7 @@
1717
Usage:
1818
1. Define an agent_portrayal function to specify how agents should be displayed
1919
2. Set up model_params to define adjustable parameters
20-
3. Create a JupyterViz instance with your model, parameters, and desired measures
20+
3. Create a SolaraViz instance with your model, parameters, and desired measures
2121
4. Display the visualization in a Jupyter notebook or run as a Solara app
2222
2323
See the Visualization Tutorial and example models for more details.
@@ -85,7 +85,7 @@ def Card(
8585

8686

8787
@solara.component
88-
def JupyterViz(
88+
def SolaraViz(
8989
model_class,
9090
model_params,
9191
measures=None,
@@ -202,6 +202,9 @@ def do_reseed():
202202
)
203203

204204

205+
JupyterViz = SolaraViz
206+
207+
205208
@solara.component
206209
def ModelController(model, play_interval, current_step, reset_counter):
207210
"""

tests/test_jupyter_viz.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import solara
66

77
import mesa
8-
from mesa.visualization.jupyter_viz import JupyterViz, Slider, UserInputs
8+
from mesa.visualization.jupyter_viz import Slider, SolaraViz, UserInputs
99

1010

1111
class TestMakeUserInput(unittest.TestCase):
@@ -101,7 +101,7 @@ def test_call_space_drawer(mocker):
101101
# initialize with space drawer unspecified (use default)
102102
# component must be rendered for code to run
103103
solara.render(
104-
JupyterViz(
104+
SolaraViz(
105105
model_class=mesa.Model,
106106
model_params={},
107107
agent_portrayal=agent_portrayal,
@@ -116,7 +116,7 @@ def test_call_space_drawer(mocker):
116116
for falsy_value in [None, False, 0]:
117117
mock_space_matplotlib.reset_mock()
118118
solara.render(
119-
JupyterViz(
119+
SolaraViz(
120120
model_class=mesa.Model,
121121
model_params={},
122122
agent_portrayal=agent_portrayal,
@@ -129,7 +129,7 @@ def test_call_space_drawer(mocker):
129129
# specify a custom space method
130130
altspace_drawer = Mock()
131131
solara.render(
132-
JupyterViz(
132+
SolaraViz(
133133
model_class=mesa.Model,
134134
model_params={},
135135
agent_portrayal=agent_portrayal,

0 commit comments

Comments
 (0)