Mesa 2.3.0rc1__py3-none-any.whl → 2.3.2__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/datacollection.py +11 -6
- mesa/experimental/components/matplotlib.py +1 -1
- mesa/space.py +1 -0
- {mesa-2.3.0rc1.dist-info → mesa-2.3.2.dist-info}/METADATA +1 -1
- {mesa-2.3.0rc1.dist-info → mesa-2.3.2.dist-info}/RECORD +10 -10
- {mesa-2.3.0rc1.dist-info → mesa-2.3.2.dist-info}/WHEEL +1 -1
- {mesa-2.3.0rc1.dist-info → mesa-2.3.2.dist-info}/entry_points.txt +0 -0
- {mesa-2.3.0rc1.dist-info → mesa-2.3.2.dist-info}/licenses/LICENSE +0 -0
mesa/__init__.py
CHANGED
|
@@ -26,7 +26,7 @@ __all__ = [
|
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
__title__ = "mesa"
|
|
29
|
-
__version__ = "2.3.
|
|
29
|
+
__version__ = "2.3.2"
|
|
30
30
|
__license__ = "Apache 2.0"
|
|
31
31
|
_this_year = datetime.datetime.now(tz=datetime.timezone.utc).date().year
|
|
32
32
|
__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)
|
mesa/datacollection.py
CHANGED
|
@@ -36,6 +36,7 @@ The default DataCollector here makes several assumptions:
|
|
|
36
36
|
import contextlib
|
|
37
37
|
import itertools
|
|
38
38
|
import types
|
|
39
|
+
from copy import deepcopy
|
|
39
40
|
from functools import partial
|
|
40
41
|
|
|
41
42
|
with contextlib.suppress(ImportError):
|
|
@@ -197,17 +198,21 @@ class DataCollector:
|
|
|
197
198
|
for var, reporter in self.model_reporters.items():
|
|
198
199
|
# Check if lambda or partial function
|
|
199
200
|
if isinstance(reporter, (types.LambdaType, partial)):
|
|
200
|
-
|
|
201
|
+
# Use deepcopy to store a copy of the data,
|
|
202
|
+
# preventing references from being updated across steps.
|
|
203
|
+
self.model_vars[var].append(deepcopy(reporter(model)))
|
|
201
204
|
# Check if model attribute
|
|
202
205
|
elif isinstance(reporter, str):
|
|
203
|
-
self.model_vars[var].append(
|
|
206
|
+
self.model_vars[var].append(
|
|
207
|
+
deepcopy(getattr(model, reporter, None))
|
|
208
|
+
)
|
|
204
209
|
# Check if function with arguments
|
|
205
210
|
elif isinstance(reporter, list):
|
|
206
|
-
self.model_vars[var].append(reporter[0](*reporter[1]))
|
|
207
|
-
#
|
|
208
|
-
#
|
|
211
|
+
self.model_vars[var].append(deepcopy(reporter[0](*reporter[1])))
|
|
212
|
+
# Assume it's a callable otherwise (e.g., method)
|
|
213
|
+
# TODO: Check if method of a class explicitly
|
|
209
214
|
else:
|
|
210
|
-
self.model_vars[var].append(reporter())
|
|
215
|
+
self.model_vars[var].append(deepcopy(reporter()))
|
|
211
216
|
|
|
212
217
|
if self.agent_reporters:
|
|
213
218
|
agent_records = self._record_agents(model)
|
|
@@ -50,7 +50,7 @@ def _draw_grid(space, space_ax, agent_portrayal):
|
|
|
50
50
|
out = {"x": x, "y": y}
|
|
51
51
|
# This is the default value for the marker size, which auto-scales
|
|
52
52
|
# according to the grid area.
|
|
53
|
-
out["s"] = (180 /
|
|
53
|
+
out["s"] = (180 / max(g.width, g.height)) ** 2
|
|
54
54
|
if len(s) > 0:
|
|
55
55
|
out["s"] = s
|
|
56
56
|
if len(c) > 0:
|
mesa/space.py
CHANGED
|
@@ -461,6 +461,7 @@ class _Grid:
|
|
|
461
461
|
# Find the closest position without sorting all positions
|
|
462
462
|
closest_pos = None
|
|
463
463
|
min_distance = float("inf")
|
|
464
|
+
agent.random.shuffle(pos)
|
|
464
465
|
for p in pos:
|
|
465
466
|
distance = self._distance_squared(p, current_pos)
|
|
466
467
|
if distance < min_distance:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
mesa/__init__.py,sha256=
|
|
1
|
+
mesa/__init__.py,sha256=RCqef0h4LAQ22-08TJ7MCVevBPwZ7Sjmddn5GSfvalE,680
|
|
2
2
|
mesa/agent.py,sha256=L_kHMM3lTVLq8EM3UsX1xVLLo-P5IqFrJEqg83gT7xs,12902
|
|
3
|
-
mesa/batchrunner.py,sha256=
|
|
4
|
-
mesa/datacollection.py,sha256=
|
|
3
|
+
mesa/batchrunner.py,sha256=G-sj2g6N6E0BsBikYq5yKsgTNnKHr4ADBkRWa9PXkl8,6055
|
|
4
|
+
mesa/datacollection.py,sha256=wJwt-bOU8WuXZomUg8JJhtIg4KMhoqXS0Zvyjv9SCAE,11445
|
|
5
5
|
mesa/main.py,sha256=7MovfNz88VWNnfXP0kcERB6C3GfkVOh0hb0o32hM9LU,1602
|
|
6
6
|
mesa/model.py,sha256=RxTCJUBfEgRIu3dXiMK9oMlxS3owwNQaQIrVRs6HsZY,5823
|
|
7
|
-
mesa/space.py,sha256=
|
|
7
|
+
mesa/space.py,sha256=K2QsFXbBPPSzsPQMJMxERNX0kJ5dhlp0NNrWxuQpq-Q,62471
|
|
8
8
|
mesa/time.py,sha256=G83UKWeMFMnQV9-79Ps2gbD_Qz3hM07IFYLzf5Rvz1w,15243
|
|
9
9
|
mesa/cookiecutter-mesa/cookiecutter.json,sha256=tBSWli39fOWUXGfiDCTKd92M7uKaBIswXbkOdbUufYY,337
|
|
10
10
|
mesa/cookiecutter-mesa/hooks/post_gen_project.py,sha256=8JoXZKIioRYEWJURC0udj8WS3rg0c4So62sOZSGbrMY,294
|
|
@@ -25,7 +25,7 @@ mesa/experimental/cell_space/discrete_space.py,sha256=ta__YojsrrhWL4DgMzUqZpSgbe
|
|
|
25
25
|
mesa/experimental/cell_space/grid.py,sha256=IltngMSlMwLsJSNYrs6B4J5ylUbL5Vk1vPX_OhWGzTs,6949
|
|
26
26
|
mesa/experimental/cell_space/network.py,sha256=NWEdROFyO18pHOTb6_t9zjjUyGhAztPJm8a9b21c8ZU,1195
|
|
27
27
|
mesa/experimental/components/altair.py,sha256=_atxt79OpRjykAEwockKm0K9dp1jDPmcLeKqffZ0Bfo,2397
|
|
28
|
-
mesa/experimental/components/matplotlib.py,sha256=
|
|
28
|
+
mesa/experimental/components/matplotlib.py,sha256=2toQmjvd1_xj_jxdQPRmpDLeuvWvZPc-eUxasM1iico,4325
|
|
29
29
|
mesa/experimental/devs/__init__.py,sha256=CWam15vCj-RD_biMyqv4sJfos1fsL823P7MDEGrbwW8,174
|
|
30
30
|
mesa/experimental/devs/eventlist.py,sha256=H9hufe9VmwvlXQr146wCa7PgbzVvivG4Bk9rlEERZ7A,4880
|
|
31
31
|
mesa/experimental/devs/simulator.py,sha256=NQ3rtBIzykBtMWNslG_Fg04NQn2lYT8cmH-7ndr8v0Y,9530
|
|
@@ -38,8 +38,8 @@ mesa/visualization/TextVisualization.py,sha256=BIP0XcmIdYhz0igqe8yRZXlXeOOqJZeu8
|
|
|
38
38
|
mesa/visualization/UserParam.py,sha256=D3qxoX-Cpqhyn06IdIO_C5s0u8nlhv3988lVwkBlcGo,49
|
|
39
39
|
mesa/visualization/__init__.py,sha256=5fwVAzgVsmxAzgoLxdC26l2ZE-m2bWj963xPNSDaQEQ,287
|
|
40
40
|
mesa/visualization/modules.py,sha256=pf6K3KECX51VNNqpFCm2EE5KV0A22UYmfXzTVXPnF_o,47
|
|
41
|
-
mesa-2.3.
|
|
42
|
-
mesa-2.3.
|
|
43
|
-
mesa-2.3.
|
|
44
|
-
mesa-2.3.
|
|
45
|
-
mesa-2.3.
|
|
41
|
+
mesa-2.3.2.dist-info/METADATA,sha256=3OPaz-uQsAtZju8pgABMiybxBB5pJZ9MilrZy_EtU4A,7865
|
|
42
|
+
mesa-2.3.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
43
|
+
mesa-2.3.2.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
|
|
44
|
+
mesa-2.3.2.dist-info/licenses/LICENSE,sha256=OGUgret9fRrm8J3pdsPXETIjf0H8puK_Nmy970ZzT78,572
|
|
45
|
+
mesa-2.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|