Mesa 2.3.1__py3-none-any.whl → 2.3.3__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.1"
29
+ __version__ = "2.3.3"
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/agent.py CHANGED
@@ -274,6 +274,21 @@ class AgentSet(MutableSet, Sequence):
274
274
  for agent in self._agents
275
275
  ]
276
276
 
277
+ def set(self, attr_name: str, value: Any) -> AgentSet:
278
+ """
279
+ Set a specified attribute to a given value for all agents in the AgentSet.
280
+
281
+ Args:
282
+ attr_name (str): The name of the attribute to set.
283
+ value (Any): The value to set the attribute to.
284
+
285
+ Returns:
286
+ AgentSet: The AgentSet instance itself, after setting the attribute.
287
+ """
288
+ for agent in self:
289
+ setattr(agent, attr_name, value)
290
+ return self
291
+
277
292
  def __getitem__(self, item: int | slice) -> Agent:
278
293
  """
279
294
  Retrieve an agent or a slice of agents from the AgentSet.
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.schedule.steps <= max_steps:
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.schedule.steps, data_collection_period))
141
- if not steps or steps[-1] != model.schedule.steps - 1:
142
- steps.append(model.schedule.steps - 1)
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)
@@ -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 / min(g.width, g.height)) ** 2
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
@@ -586,7 +586,7 @@ class PropertyLayer:
586
586
  aggregate_property(operation): Performs an aggregate operation over all cells.
587
587
  """
588
588
 
589
- agentset_experimental_warning_given = False
589
+ propertylayer_experimental_warning_given = False
590
590
 
591
591
  def __init__(
592
592
  self, name: str, width: int, height: int, default_value, dtype=np.float64
@@ -633,14 +633,14 @@ class PropertyLayer:
633
633
 
634
634
  self.data = np.full((width, height), default_value, dtype=dtype)
635
635
 
636
- if not self.__class__.agentset_experimental_warning_given:
636
+ if not self.__class__.propertylayer_experimental_warning_given:
637
637
  warnings.warn(
638
638
  "The new PropertyLayer and _PropertyGrid classes experimental. It may be changed or removed in any and all future releases, including patch releases.\n"
639
639
  "We would love to hear what you think about this new feature. If you have any thoughts, share them with us here: https://github.com/projectmesa/mesa/discussions/1932",
640
640
  FutureWarning,
641
641
  stacklevel=2,
642
642
  )
643
- self.__class__.agentset_experimental_warning_given = True
643
+ self.__class__.propertylayer_experimental_warning_given = True
644
644
 
645
645
  def set_cell(self, position: Coordinate, value):
646
646
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Mesa
3
- Version: 2.3.1
3
+ Version: 2.3.3
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
@@ -32,7 +32,6 @@ Requires-Dist: pandas
32
32
  Requires-Dist: solara
33
33
  Requires-Dist: tqdm
34
34
  Provides-Extra: dev
35
- Requires-Dist: coverage; extra == 'dev'
36
35
  Requires-Dist: pytest-cov; extra == 'dev'
37
36
  Requires-Dist: pytest-mock; extra == 'dev'
38
37
  Requires-Dist: pytest>=4.6; extra == 'dev'
@@ -56,6 +55,8 @@ Description-Content-Type: text/markdown
56
55
  | Meta | [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) |
57
56
  | Chat | [![chat](https://img.shields.io/matrix/project-mesa:matrix.org?label=chat&logo=Matrix)](https://matrix.to/#/#project-mesa:matrix.org) |
58
57
 
58
+ *This is the `2.3.x-maintenance` branch. Example models for Mesa 2.x can be found [here](https://github.com/projectmesa/mesa-examples/tree/mesa-2.x/examples).*
59
+
59
60
  Mesa allows users to quickly create agent-based models using built-in
60
61
  core components (such as spatial grids and agent schedulers) or
61
62
  customized implementations; visualize them using a browser-based
@@ -95,15 +96,18 @@ Or any other (development) branch on this repo or your own fork:
95
96
  pip install -U -e git+https://github.com/YOUR_FORK/mesa@YOUR_BRANCH#egg=mesa
96
97
  ```
97
98
 
99
+ ## Resources
98
100
  For resources or help on using Mesa, check out the following:
99
101
 
100
102
  - [Intro to Mesa Tutorial](http://mesa.readthedocs.org/en/stable/tutorials/intro_tutorial.html) (An introductory model, the Boltzmann
101
103
  Wealth Model, for beginners or those new to Mesa.)
104
+ - [Visualization Tutorial](https://mesa.readthedocs.io/en/stable/tutorials/visualization_tutorial.html) (An introduction into our Solara visualization)
102
105
  - [Complexity Explorer Tutorial](https://www.complexityexplorer.org/courses/172-agent-based-models-with-python-an-introduction-to-mesa) (An advanced-beginner model,
103
106
  SugarScape with Traders, with instructional videos)
104
- - [Mesa Examples](https://github.com/projectmesa/mesa-examples/tree/main/examples) (A repository of seminal ABMs using Mesa and
107
+ - [Mesa Examples](https://github.com/projectmesa/mesa-examples/tree/mesa-2.x/examples) (A repository of seminal ABMs using Mesa and
105
108
  examples of employing specific Mesa Features)
106
109
  - [Docs](http://mesa.readthedocs.org/) (Mesa's documentation, API and useful snippets)
110
+ - [Development version docs](https://mesa.readthedocs.io/en/latest/) (the latest version docs if you're using a pre-release Mesa version)
107
111
  - [Discussions](https://github.com/projectmesa/mesa/discussions) (GitHub threaded discussions about Mesa)
108
112
  - [Matrix Chat](https://matrix.to/#/#project-mesa:matrix.org) (Chat Forum via Matrix to talk about Mesa)
109
113
 
@@ -1,10 +1,10 @@
1
- mesa/__init__.py,sha256=dspGeuz4yLyjSg4fxTGIW0gCO61g9D8QH_0bNctLdCA,680
2
- mesa/agent.py,sha256=L_kHMM3lTVLq8EM3UsX1xVLLo-P5IqFrJEqg83gT7xs,12902
3
- mesa/batchrunner.py,sha256=2A1_FbFlSCkDm8xfv1ZamFiBE4VYce8sKP5SR_CledE,6087
1
+ mesa/__init__.py,sha256=u5__ZD3UVmOyHjlWg3o0N_Zw62nexYpkJDX9dtv1RFM,680
2
+ mesa/agent.py,sha256=db7xGHY0mWgasp-zqC3NgCz_aQoBMHA8DuErK3o7hfk,13398
3
+ mesa/batchrunner.py,sha256=G-sj2g6N6E0BsBikYq5yKsgTNnKHr4ADBkRWa9PXkl8,6055
4
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=K2QsFXbBPPSzsPQMJMxERNX0kJ5dhlp0NNrWxuQpq-Q,62471
7
+ mesa/space.py,sha256=luMN5D6rBluEpkKJGRwmueAgsf4_txzLfnLvMXk3k60,62486
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=DVf41wdN1J56IQJXaeonqL4rcwYlsUIUB7C6r5ozdfg,4325
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.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,,
41
+ mesa-2.3.3.dist-info/METADATA,sha256=qcguKNcGx6DtQnUq71zfppuSi3yxftOXG3EDPJFYAHc,8301
42
+ mesa-2.3.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
43
+ mesa-2.3.3.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
44
+ mesa-2.3.3.dist-info/licenses/LICENSE,sha256=OGUgret9fRrm8J3pdsPXETIjf0H8puK_Nmy970ZzT78,572
45
+ mesa-2.3.3.dist-info/RECORD,,
File without changes