Mesa 3.0.0a0__py3-none-any.whl → 3.0.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Mesa might be problematic. Click here for more details.
- mesa/__init__.py +1 -1
- mesa/batchrunner.py +4 -4
- mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +2 -2
- mesa/visualization/__init__.py +2 -2
- mesa/visualization/components/matplotlib.py +1 -1
- mesa/visualization/{jupyter_viz.py → solara_viz.py} +43 -84
- {mesa-3.0.0a0.dist-info → mesa-3.0.0a1.dist-info}/METADATA +1 -1
- {mesa-3.0.0a0.dist-info → mesa-3.0.0a1.dist-info}/RECORD +11 -11
- {mesa-3.0.0a0.dist-info → mesa-3.0.0a1.dist-info}/WHEEL +0 -0
- {mesa-3.0.0a0.dist-info → mesa-3.0.0a1.dist-info}/entry_points.txt +0 -0
- {mesa-3.0.0a0.dist-info → mesa-3.0.0a1.dist-info}/licenses/LICENSE +0 -0
mesa/__init__.py
CHANGED
|
@@ -24,7 +24,7 @@ __all__ = [
|
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
__title__ = "mesa"
|
|
27
|
-
__version__ = "3.0.
|
|
27
|
+
__version__ = "3.0.0a1"
|
|
28
28
|
__license__ = "Apache 2.0"
|
|
29
29
|
_this_year = datetime.datetime.now(tz=datetime.timezone.utc).date().year
|
|
30
30
|
__copyright__ = f"Copyright {_this_year} Project Mesa Team"
|
mesa/batchrunner.py
CHANGED
|
@@ -132,14 +132,14 @@ def _model_run_func(
|
|
|
132
132
|
"""
|
|
133
133
|
run_id, iteration, kwargs = run
|
|
134
134
|
model = model_cls(**kwargs)
|
|
135
|
-
while model.running and model.
|
|
135
|
+
while model.running and model._steps <= max_steps:
|
|
136
136
|
model.step()
|
|
137
137
|
|
|
138
138
|
data = []
|
|
139
139
|
|
|
140
|
-
steps = list(range(0, model.
|
|
141
|
-
if not steps or steps[-1] != model.
|
|
142
|
-
steps.append(model.
|
|
140
|
+
steps = list(range(0, model._steps, data_collection_period))
|
|
141
|
+
if not steps or steps[-1] != model._steps - 1:
|
|
142
|
+
steps.append(model._steps - 1)
|
|
143
143
|
|
|
144
144
|
for step in steps:
|
|
145
145
|
model_data, all_agents_data = _collect_data(model, step)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Configure visualization elements and instantiate a server
|
|
3
3
|
"""
|
|
4
|
-
from mesa.visualization import
|
|
4
|
+
from mesa.visualization import SolaraViz
|
|
5
5
|
|
|
6
6
|
from {{ cookiecutter.snake }}.model import {{ cookiecutter.model }}, {{ cookiecutter.agent }} # noqa
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ def circle_portrayal_example(agent):
|
|
|
18
18
|
|
|
19
19
|
model_params = {"num_agents": 10, "width": 10, "height": 10}
|
|
20
20
|
|
|
21
|
-
page =
|
|
21
|
+
page = SolaraViz(
|
|
22
22
|
{{cookiecutter.model}},
|
|
23
23
|
model_params,
|
|
24
24
|
measures=["num_agents"],
|
mesa/visualization/__init__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .solara_viz import JupyterViz, Slider, SolaraViz, make_text
|
|
2
2
|
|
|
3
|
-
__all__ = ["JupyterViz", "make_text", "Slider"]
|
|
3
|
+
__all__ = ["JupyterViz", "make_text", "Slider", "SolaraViz"]
|
|
@@ -48,7 +48,7 @@ def _draw_grid(space, space_ax, agent_portrayal):
|
|
|
48
48
|
out = {"x": x, "y": y}
|
|
49
49
|
# This is the default value for the marker size, which auto-scales
|
|
50
50
|
# according to the grid area.
|
|
51
|
-
out["s"] = (180 /
|
|
51
|
+
out["s"] = (180 / max(g.width, g.height)) ** 2
|
|
52
52
|
if len(s) > 0:
|
|
53
53
|
out["s"] = s
|
|
54
54
|
if len(c) > 0:
|
|
@@ -5,7 +5,7 @@ This module provides components to create browser- and Jupyter notebook-based vi
|
|
|
5
5
|
Mesa models, allowing users to watch models run step-by-step and interact with model parameters.
|
|
6
6
|
|
|
7
7
|
Key features:
|
|
8
|
-
-
|
|
8
|
+
- SolaraViz: Main component for creating visualizations, supporting grid displays and plots
|
|
9
9
|
- ModelController: Handles model execution controls (step, play, pause, reset)
|
|
10
10
|
- UserInputs: Generates UI elements for adjusting model parameters
|
|
11
11
|
- Card: Renders individual visualization elements (space, measures)
|
|
@@ -17,13 +17,12 @@ custom visualization components.
|
|
|
17
17
|
Usage:
|
|
18
18
|
1. Define an agent_portrayal function to specify how agents should be displayed
|
|
19
19
|
2. Set up model_params to define adjustable parameters
|
|
20
|
-
3. Create a
|
|
20
|
+
3. Create a SolaraViz instance with your model, parameters, and desired measures
|
|
21
21
|
4. Display the visualization in a Jupyter notebook or run as a Solara app
|
|
22
22
|
|
|
23
23
|
See the Visualization Tutorial and example models for more details.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
import sys
|
|
27
26
|
import threading
|
|
28
27
|
|
|
29
28
|
import reacton.ipywidgets as widgets
|
|
@@ -86,7 +85,7 @@ def Card(
|
|
|
86
85
|
|
|
87
86
|
|
|
88
87
|
@solara.component
|
|
89
|
-
def
|
|
88
|
+
def SolaraViz(
|
|
90
89
|
model_class,
|
|
91
90
|
model_params,
|
|
92
91
|
measures=None,
|
|
@@ -158,92 +157,52 @@ def JupyterViz(
|
|
|
158
157
|
"""Update the random seed for the model."""
|
|
159
158
|
reactive_seed.value = model.random.random()
|
|
160
159
|
|
|
161
|
-
# jupyter
|
|
162
160
|
dependencies = [current_step.value, reactive_seed.value]
|
|
163
161
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
with solara.GridFixed(columns=2):
|
|
167
|
-
UserInputs(user_params, on_change=handle_change_model_params)
|
|
168
|
-
ModelController(model, play_interval, current_step, reset_counter)
|
|
169
|
-
solara.Markdown(md_text=f"###Step - {current_step}")
|
|
162
|
+
# if space drawer is disabled, do not include it
|
|
163
|
+
layout_types = [{"Space": "default"}] if space_drawer else []
|
|
170
164
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
# if specified, draw agent space with an alternate renderer
|
|
184
|
-
space_drawer(model, agent_portrayal)
|
|
185
|
-
# otherwise, do nothing (do not draw space)
|
|
186
|
-
|
|
187
|
-
# 5. Plots
|
|
188
|
-
if measures:
|
|
189
|
-
for measure in measures:
|
|
190
|
-
if callable(measure):
|
|
191
|
-
# Is a custom object
|
|
192
|
-
measure(model)
|
|
193
|
-
else:
|
|
194
|
-
components_matplotlib.PlotMatplotlib(
|
|
195
|
-
model, measure, dependencies=dependencies
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
def render_in_browser():
|
|
199
|
-
"""Render the visualization components in a web browser."""
|
|
200
|
-
# if space drawer is disabled, do not include it
|
|
201
|
-
layout_types = [{"Space": "default"}] if space_drawer else []
|
|
202
|
-
|
|
203
|
-
if measures:
|
|
204
|
-
layout_types += [{"Measure": elem} for elem in range(len(measures))]
|
|
205
|
-
|
|
206
|
-
grid_layout_initial = make_initial_grid_layout(layout_types=layout_types)
|
|
207
|
-
grid_layout, set_grid_layout = solara.use_state(grid_layout_initial)
|
|
208
|
-
|
|
209
|
-
with solara.Sidebar():
|
|
210
|
-
with solara.Card("Controls", margin=1, elevation=2):
|
|
211
|
-
solara.InputText(
|
|
212
|
-
label="Seed",
|
|
213
|
-
value=reactive_seed,
|
|
214
|
-
continuous_update=True,
|
|
215
|
-
)
|
|
216
|
-
UserInputs(user_params, on_change=handle_change_model_params)
|
|
217
|
-
ModelController(model, play_interval, current_step, reset_counter)
|
|
218
|
-
solara.Button(label="Reseed", color="primary", on_click=do_reseed)
|
|
219
|
-
with solara.Card("Information", margin=1, elevation=2):
|
|
220
|
-
solara.Markdown(md_text=f"Step - {current_step}")
|
|
221
|
-
|
|
222
|
-
items = [
|
|
223
|
-
Card(
|
|
224
|
-
model,
|
|
225
|
-
measures,
|
|
226
|
-
agent_portrayal,
|
|
227
|
-
space_drawer,
|
|
228
|
-
dependencies,
|
|
229
|
-
color="white",
|
|
230
|
-
layout_type=layout_types[i],
|
|
165
|
+
if measures:
|
|
166
|
+
layout_types += [{"Measure": elem} for elem in range(len(measures))]
|
|
167
|
+
|
|
168
|
+
grid_layout_initial = make_initial_grid_layout(layout_types=layout_types)
|
|
169
|
+
grid_layout, set_grid_layout = solara.use_state(grid_layout_initial)
|
|
170
|
+
|
|
171
|
+
with solara.Sidebar():
|
|
172
|
+
with solara.Card("Controls", margin=1, elevation=2):
|
|
173
|
+
solara.InputText(
|
|
174
|
+
label="Seed",
|
|
175
|
+
value=reactive_seed,
|
|
176
|
+
continuous_update=True,
|
|
231
177
|
)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
178
|
+
UserInputs(user_params, on_change=handle_change_model_params)
|
|
179
|
+
ModelController(model, play_interval, current_step, reset_counter)
|
|
180
|
+
solara.Button(label="Reseed", color="primary", on_click=do_reseed)
|
|
181
|
+
with solara.Card("Information", margin=1, elevation=2):
|
|
182
|
+
solara.Markdown(md_text=f"Step - {current_step}")
|
|
183
|
+
|
|
184
|
+
items = [
|
|
185
|
+
Card(
|
|
186
|
+
model,
|
|
187
|
+
measures,
|
|
188
|
+
agent_portrayal,
|
|
189
|
+
space_drawer,
|
|
190
|
+
dependencies,
|
|
191
|
+
color="white",
|
|
192
|
+
layout_type=layout_types[i],
|
|
240
193
|
)
|
|
194
|
+
for i in range(len(layout_types))
|
|
195
|
+
]
|
|
196
|
+
solara.GridDraggable(
|
|
197
|
+
items=items,
|
|
198
|
+
grid_layout=grid_layout,
|
|
199
|
+
resizable=True,
|
|
200
|
+
draggable=True,
|
|
201
|
+
on_grid_layout=set_grid_layout,
|
|
202
|
+
)
|
|
203
|
+
|
|
241
204
|
|
|
242
|
-
|
|
243
|
-
# When in Jupyter or Google Colab
|
|
244
|
-
render_in_jupyter()
|
|
245
|
-
else:
|
|
246
|
-
render_in_browser()
|
|
205
|
+
JupyterViz = SolaraViz
|
|
247
206
|
|
|
248
207
|
|
|
249
208
|
@solara.component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
mesa/__init__.py,sha256=
|
|
1
|
+
mesa/__init__.py,sha256=XNwJOFa_LglQJTMbYPWHXvartntKeOrSn9DGSbXj1rc,618
|
|
2
2
|
mesa/agent.py,sha256=fx_h8RnX5DJCmfJtloIb_fprXXp8bFzC3_RnLOLlOvY,12902
|
|
3
|
-
mesa/batchrunner.py,sha256=
|
|
3
|
+
mesa/batchrunner.py,sha256=92MabDDR38XGTZw_IB7nNDNH0PX7zL_jGyZJ2grisaY,6023
|
|
4
4
|
mesa/datacollection.py,sha256=CQ2QsW-mkEVbDVTsOkLy8NAQEKeoILdLB0zWS2sxnyk,11444
|
|
5
5
|
mesa/main.py,sha256=7MovfNz88VWNnfXP0kcERB6C3GfkVOh0hb0o32hM9LU,1602
|
|
6
6
|
mesa/model.py,sha256=GqayRWhohSS96kMwHCNGI7XvEkwI8GHS2SRL6SZ9N5E,5810
|
|
@@ -9,7 +9,7 @@ mesa/time.py,sha256=9gNoyUqYkt_gUPFBMhm38pK87mcntwAZ1lJzxqW3BSA,15211
|
|
|
9
9
|
mesa/cookiecutter-mesa/cookiecutter.json,sha256=tBSWli39fOWUXGfiDCTKd92M7uKaBIswXbkOdbUufYY,337
|
|
10
10
|
mesa/cookiecutter-mesa/hooks/post_gen_project.py,sha256=8JoXZKIioRYEWJURC0udj8WS3rg0c4So62sOZSGbrMY,294
|
|
11
11
|
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md,sha256=Yji4lGY-NtQSnW-oBj0_Jhs-XhCfZA8R1mBBM_IllGs,80
|
|
12
|
-
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate,sha256=
|
|
12
|
+
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate,sha256=36f9k9CH6TK6VrXsPvTFXGUfCKzCLwgYTeK-Gt27GNg,584
|
|
13
13
|
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate,sha256=UtRpLM_CkeUZRec-Ef_LiO_x7SKaWN11fOiH9T1UmTw,214
|
|
14
14
|
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate,sha256=Aml4Z6E1yj7E7DtHNSUqnKNRUdkxG9WWtJyW8fkxCng,1870
|
|
@@ -27,12 +27,12 @@ mesa/experimental/devs/simulator.py,sha256=0SMC7daIOyL2rYfoQOOTaTOYDos0gLeBUbU1K
|
|
|
27
27
|
mesa/experimental/devs/examples/epstein_civil_violence.py,sha256=KqH9KI-A_BYt7oWi9kaOhTzjrf2pETqzSpAQG8ewud0,9667
|
|
28
28
|
mesa/experimental/devs/examples/wolf_sheep.py,sha256=h5z-eDqMpYeOjrq293N2BcQbs_LDVsgtg9vblXJM7XQ,7697
|
|
29
29
|
mesa/visualization/UserParam.py,sha256=WgnY3Q0padtGqUCaezgYzd6cZ7LziuIQnGKP3DBuHZY,1641
|
|
30
|
-
mesa/visualization/__init__.py,sha256=
|
|
31
|
-
mesa/visualization/
|
|
30
|
+
mesa/visualization/__init__.py,sha256=zsAzEY3-0O9CZUfiUL6p8zCR1mvvL5Sai2WzoiQ2pmY,127
|
|
31
|
+
mesa/visualization/solara_viz.py,sha256=POus4i1k2Z8fJpEXiXQvGupRsrRLRiG5qndwkaEQ53Y,15085
|
|
32
32
|
mesa/visualization/components/altair.py,sha256=V2CQ-Zr7PeijgWtYBNH3VklGVfrf1ee70XVh0DBBONQ,2366
|
|
33
|
-
mesa/visualization/components/matplotlib.py,sha256=
|
|
34
|
-
mesa-3.0.
|
|
35
|
-
mesa-3.0.
|
|
36
|
-
mesa-3.0.
|
|
37
|
-
mesa-3.0.
|
|
38
|
-
mesa-3.0.
|
|
33
|
+
mesa/visualization/components/matplotlib.py,sha256=lB9QKo6i_mI2iKCksyakOStqY8I6B3sv8SXcpmPgWEc,4289
|
|
34
|
+
mesa-3.0.0a1.dist-info/METADATA,sha256=QTL6KViiX07VnrkXi5hqG0nYYN_hyZaWo3_SckVvbIA,7771
|
|
35
|
+
mesa-3.0.0a1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
36
|
+
mesa-3.0.0a1.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
|
|
37
|
+
mesa-3.0.0a1.dist-info/licenses/LICENSE,sha256=OGUgret9fRrm8J3pdsPXETIjf0H8puK_Nmy970ZzT78,572
|
|
38
|
+
mesa-3.0.0a1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|