Mesa 2.3.0rc1__py3-none-any.whl → 2.3.1__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 CHANGED
@@ -26,7 +26,7 @@ __all__ = [
26
26
  ]
27
27
 
28
28
  __title__ = "mesa"
29
- __version__ = "2.3.0-rc1"
29
+ __version__ = "2.3.1"
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/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
- self.model_vars[var].append(reporter(model))
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(getattr(model, reporter, None))
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
- # TODO: Check if method of a class, as of now it is assumed
208
- # implicitly if the other checks fail.
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)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Mesa
3
- Version: 2.3.0rc1
3
+ Version: 2.3.1
4
4
  Summary: Agent-based modeling (ABM) in Python
5
5
  Project-URL: homepage, https://github.com/projectmesa/mesa
6
6
  Project-URL: repository, https://github.com/projectmesa/mesa
@@ -1,10 +1,10 @@
1
- mesa/__init__.py,sha256=zv1ix1DhUDQ7zQETpTWaa_9Dk74c4kWbJlkha7OM9W0,684
1
+ mesa/__init__.py,sha256=dspGeuz4yLyjSg4fxTGIW0gCO61g9D8QH_0bNctLdCA,680
2
2
  mesa/agent.py,sha256=L_kHMM3lTVLq8EM3UsX1xVLLo-P5IqFrJEqg83gT7xs,12902
3
3
  mesa/batchrunner.py,sha256=2A1_FbFlSCkDm8xfv1ZamFiBE4VYce8sKP5SR_CledE,6087
4
- mesa/datacollection.py,sha256=Iwz8Nuib1Fmo8sJ0ng-qstBhAkdKXn-CXomylCkCRGQ,11195
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=A3QUZV7BLbo29dQhvorsgCAFxnJ2i21a5Vxd53wbIWo,62429
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
@@ -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.0rc1.dist-info/METADATA,sha256=AhVQypSMMIg-Tji_x28Qid8g82bn2LSW-UTgcaZ5t4A,7868
42
- mesa-2.3.0rc1.dist-info/WHEEL,sha256=osohxoshIHTFJFVPhsi1UkZuLRGMHRXZzwEBW2ezjrc,87
43
- mesa-2.3.0rc1.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
44
- mesa-2.3.0rc1.dist-info/licenses/LICENSE,sha256=OGUgret9fRrm8J3pdsPXETIjf0H8puK_Nmy970ZzT78,572
45
- mesa-2.3.0rc1.dist-info/RECORD,,
41
+ mesa-2.3.1.dist-info/METADATA,sha256=Xe3sFfvBz_SMqV-ib9mHBoK_ogWw8VFKIqT2-bbJw1A,7865
42
+ mesa-2.3.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
43
+ mesa-2.3.1.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
44
+ mesa-2.3.1.dist-info/licenses/LICENSE,sha256=OGUgret9fRrm8J3pdsPXETIjf0H8puK_Nmy970ZzT78,572
45
+ mesa-2.3.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.24.1
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any