Mesa 3.0.0a0__tar.gz → 3.0.0a1__tar.gz
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-3.0.0a0 → mesa-3.0.0a1}/.gitignore +2 -4
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.readthedocs.yml +2 -2
- {mesa-3.0.0a0 → mesa-3.0.0a1}/HISTORY.md +32 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/PKG-INFO +1 -1
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/visualization.md +1 -1
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/index.md +2 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/visualization_tutorial.ipynb +4 -4
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/__init__.py +1 -1
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/batchrunner.py +4 -4
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +2 -2
- mesa-3.0.0a1/mesa/visualization/__init__.py +3 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/visualization/components/matplotlib.py +1 -1
- mesa-3.0.0a0/mesa/visualization/jupyter_viz.py → mesa-3.0.0a1/mesa/visualization/solara_viz.py +43 -84
- mesa-3.0.0a0/tests/test_jupyter_viz.py → mesa-3.0.0a1/tests/test_solara_viz.py +4 -4
- mesa-3.0.0a0/mesa/visualization/__init__.py +0 -3
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.codespellignore +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.coveragerc +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/ISSUE_TEMPLATE/asking-help.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/dependabot.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/release.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/workflows/benchmarks.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/workflows/build_lint.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.github/workflows/release.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/.pre-commit-config.yaml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/CITATION.bib +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/CODE_OF_CONDUCT.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/CONTRIBUTING.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/Dockerfile +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/LICENSE +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/README.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/Flocking/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/Flocking/flocking.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/Schelling/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/Schelling/schelling.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/WolfSheep/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/WolfSheep/wolf_sheep.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/compare_timings.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/configurations.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/benchmarks/global_benchmark.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/codecov.yaml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docker-compose.yml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/Makefile +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/README.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/api_main.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/batchrunner.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/datacollection.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/experimental.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/init.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/space.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/apis/time.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/best-practices.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/conf.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/howto.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/Mesa_Screenshot.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/mesa_logo.ico +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/mesa_logo.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/br_ginis.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/dc_endwealth.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/dc_gini.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/dc_oneagent.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/first_hist.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/multirun_hist.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/numpy_grid.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/viz_chart.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/viz_empty.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/viz_greycircles.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/viz_histogram.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/images/tutorial/viz_redcircles.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/make.bat +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/mesa.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/overview.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/packages.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/MoneyModel.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_chart.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_empty.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_greycircles.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_histogram.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_redcircles.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/files/viz_slider.png +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/docs/tutorials/intro_tutorial.ipynb +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/maintenance/fetch_unlabeled_prs.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/agent.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/cookiecutter.json +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/hooks/post_gen_project.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/datacollection.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/cell.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/cell_agent.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/cell_collection.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/discrete_space.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/grid.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/cell_space/network.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/devs/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/devs/eventlist.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/devs/examples/epstein_civil_violence.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/devs/examples/wolf_sheep.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/experimental/devs/simulator.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/main.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/model.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/space.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/time.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/visualization/UserParam.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/visualization/components/altair.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/mypy.ini +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/pyproject.toml +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/__init__.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/read_requirements.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_agent.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_batch_run.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_cell_space.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_datacollector.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_devs.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_end_to_end_viz.sh +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_examples.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_grid.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_import_namespace.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_lifespan.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_model.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_scaffold.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_space.py +0 -0
- {mesa-3.0.0a0 → mesa-3.0.0a1}/tests/test_time.py +0 -0
|
@@ -15,6 +15,8 @@ __pycache__/
|
|
|
15
15
|
.Python
|
|
16
16
|
env/
|
|
17
17
|
venv/
|
|
18
|
+
pythonenv*/
|
|
19
|
+
.venv/
|
|
18
20
|
build/
|
|
19
21
|
develop-eggs/
|
|
20
22
|
dist/
|
|
@@ -83,10 +85,6 @@ target/
|
|
|
83
85
|
.dmypy.json
|
|
84
86
|
dmypy.json
|
|
85
87
|
|
|
86
|
-
# pythonenv
|
|
87
|
-
pythonenv*/
|
|
88
|
-
|
|
89
88
|
# JS dependencies
|
|
90
89
|
mesa/visualization/templates/external/
|
|
91
90
|
mesa/visualization/templates/js/external/
|
|
92
|
-
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Release History
|
|
3
3
|
---
|
|
4
|
+
# 3.0.0a1 (2024-08-01)
|
|
5
|
+
## Highlights
|
|
6
|
+
Mesa 3.0 alpha 1 (`v3.0.0a1`) is another step towards our next major version. This release introduces a name change from JupyterViz (jupyter_viz) to SolaraViz (solara_viz), to better represent the tech stack being used. It also includes two bugfixes also present in 2.3.2.
|
|
7
|
+
|
|
8
|
+
## What's Changed
|
|
9
|
+
### ⚠️ Breaking changes
|
|
10
|
+
* viz: Combine code for rendering in browser and Jupyter by @rht in https://github.com/projectmesa/mesa/pull/2180
|
|
11
|
+
### 🛠 Enhancements made
|
|
12
|
+
* Rename JupyterViz to SolaraViz by @rht in https://github.com/projectmesa/mesa/pull/2187
|
|
13
|
+
* refactor: Rename jupyter_viz namespace to solara_viz by @rht in https://github.com/projectmesa/mesa/pull/2188
|
|
14
|
+
### 🐛 Bugs fixed
|
|
15
|
+
* fix: Render agent marker radius correctly by @rht in https://github.com/projectmesa/mesa/pull/2181
|
|
16
|
+
* fix: Use model.schedule.steps -> mode._steps for batch_run by @rht in https://github.com/projectmesa/mesa/pull/2183
|
|
17
|
+
### 📜 Documentation improvements
|
|
18
|
+
* Add original conference paper link to docs by @ENUMERA8OR in https://github.com/projectmesa/mesa/pull/2160
|
|
19
|
+
|
|
20
|
+
## New Contributors
|
|
21
|
+
* @ENUMERA8OR made their first contribution in https://github.com/projectmesa/mesa/pull/2160
|
|
22
|
+
|
|
23
|
+
**Full Changelog**: https://github.com/projectmesa/mesa/compare/v3.0.0a0...v3.0.0a1
|
|
24
|
+
|
|
4
25
|
# 3.0.0a0 (2024-07-04)
|
|
5
26
|
## Highlights
|
|
6
27
|
This is the first pre-release in the Mesa 3.0 series, which is still in active development. The `v3.0.0a0` pre-release can help active Mesa developers help starting to test the latest features in their models.
|
|
@@ -38,6 +59,17 @@ This pre-release can be installed with `pip install mesa --upgrade --pre`.
|
|
|
38
59
|
|
|
39
60
|
**Full Changelog**: https://github.com/projectmesa/mesa/compare/v2.3.1...v3.0.0a0
|
|
40
61
|
|
|
62
|
+
# 2.3.2 (2024-07-22)
|
|
63
|
+
## Highlights
|
|
64
|
+
Mesa 2.3.2 is a small patch release which fixes two bugs, one to the batch_run function still depending on `schedule.steps`, and one in the agent marker visualisation.
|
|
65
|
+
|
|
66
|
+
## What's Changed
|
|
67
|
+
### 🐛 Bugs fixed
|
|
68
|
+
* fix: Render agent marker radius correctly by @rht in https://github.com/projectmesa/mesa/pull/2181
|
|
69
|
+
* fix: Use model.schedule.steps -> mode._steps for batch_run by @rht in https://github.com/projectmesa/mesa/pull/2183
|
|
70
|
+
|
|
71
|
+
**Full Changelog**: https://github.com/projectmesa/mesa/compare/v2.3.1...v2.3.2
|
|
72
|
+
|
|
41
73
|
# 2.3.1 (2024-07-03)
|
|
42
74
|
## Highlights
|
|
43
75
|
Mesa 2.3.1 is a small patch release with a datacollector bug fixed and improved documentation.
|
|
@@ -5,7 +5,7 @@ For a detailed tutorial, please refer to our [Visualization Tutorial](../tutoria
|
|
|
5
5
|
## Jupyter Visualization
|
|
6
6
|
|
|
7
7
|
```{eval-rst}
|
|
8
|
-
.. automodule:: mesa.visualization.
|
|
8
|
+
.. automodule:: mesa.visualization.solara_viz
|
|
9
9
|
:members:
|
|
10
10
|
:undoc-members:
|
|
11
11
|
:show-inheritance:
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
[Mesa] is an Apache2 licensed agent-based modeling (or ABM) framework in Python.
|
|
20
20
|
|
|
21
|
+
The original conference paper is [available here](http://conference.scipy.org.s3-website-us-east-1.amazonaws.com/proceedings/scipy2015/jacqueline_kazil.html).
|
|
22
|
+
|
|
21
23
|
Mesa allows users to quickly create agent-based models using built-in core components (such as spatial grids and agent schedulers) or customized implementations; visualize them using a browser-based interface; and analyze their results using Python's data analysis tools. Its goal is to be the Python-based counterpart to NetLogo, Repast, or MASON.
|
|
22
24
|
|
|
23
25
|
|
|
@@ -119,9 +119,9 @@
|
|
|
119
119
|
},
|
|
120
120
|
"outputs": [],
|
|
121
121
|
"source": [
|
|
122
|
-
"from mesa.visualization import
|
|
122
|
+
"from mesa.visualization import SolaraViz\n",
|
|
123
123
|
"\n",
|
|
124
|
-
"page =
|
|
124
|
+
"page = SolaraViz(\n",
|
|
125
125
|
" BoltzmannWealthModel,\n",
|
|
126
126
|
" model_params,\n",
|
|
127
127
|
" measures=[\"Gini\"],\n",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"metadata": {},
|
|
165
165
|
"outputs": [],
|
|
166
166
|
"source": [
|
|
167
|
-
"page =
|
|
167
|
+
"page = SolaraViz(\n",
|
|
168
168
|
" BoltzmannWealthModel,\n",
|
|
169
169
|
" model_params,\n",
|
|
170
170
|
" measures=[\"Gini\"],\n",
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
"metadata": {},
|
|
224
224
|
"outputs": [],
|
|
225
225
|
"source": [
|
|
226
|
-
"page =
|
|
226
|
+
"page = SolaraViz(\n",
|
|
227
227
|
" BoltzmannWealthModel,\n",
|
|
228
228
|
" model_params,\n",
|
|
229
229
|
" measures=[\"Gini\", make_histogram],\n",
|
|
@@ -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"
|
|
@@ -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"],
|
|
@@ -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:
|
mesa-3.0.0a0/mesa/visualization/jupyter_viz.py → mesa-3.0.0a1/mesa/visualization/solara_viz.py
RENAMED
|
@@ -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
|
|
@@ -5,7 +5,7 @@ import ipyvuetify as vw
|
|
|
5
5
|
import solara
|
|
6
6
|
|
|
7
7
|
import mesa
|
|
8
|
-
from mesa.visualization.
|
|
8
|
+
from mesa.visualization.solara_viz import Slider, SolaraViz, UserInputs
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class TestMakeUserInput(unittest.TestCase):
|
|
@@ -101,7 +101,7 @@ def test_call_space_drawer(mocker):
|
|
|
101
101
|
# initialize with space drawer unspecified (use default)
|
|
102
102
|
# component must be rendered for code to run
|
|
103
103
|
solara.render(
|
|
104
|
-
|
|
104
|
+
SolaraViz(
|
|
105
105
|
model_class=mesa.Model,
|
|
106
106
|
model_params={},
|
|
107
107
|
agent_portrayal=agent_portrayal,
|
|
@@ -116,7 +116,7 @@ def test_call_space_drawer(mocker):
|
|
|
116
116
|
for falsy_value in [None, False, 0]:
|
|
117
117
|
mock_space_matplotlib.reset_mock()
|
|
118
118
|
solara.render(
|
|
119
|
-
|
|
119
|
+
SolaraViz(
|
|
120
120
|
model_class=mesa.Model,
|
|
121
121
|
model_params={},
|
|
122
122
|
agent_portrayal=agent_portrayal,
|
|
@@ -129,7 +129,7 @@ def test_call_space_drawer(mocker):
|
|
|
129
129
|
# specify a custom space method
|
|
130
130
|
altspace_drawer = Mock()
|
|
131
131
|
solara.render(
|
|
132
|
-
|
|
132
|
+
SolaraViz(
|
|
133
133
|
model_class=mesa.Model,
|
|
134
134
|
model_params={},
|
|
135
135
|
agent_portrayal=agent_portrayal,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mesa-3.0.0a0 → mesa-3.0.0a1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|