Mesa 3.0.0a4__py3-none-any.whl → 3.0.0b0__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.

Files changed (41) hide show
  1. mesa/__init__.py +2 -3
  2. mesa/agent.py +116 -85
  3. mesa/batchrunner.py +22 -23
  4. mesa/cookiecutter-mesa/hooks/post_gen_project.py +2 -0
  5. mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +1 -0
  6. mesa/datacollection.py +138 -27
  7. mesa/experimental/UserParam.py +17 -6
  8. mesa/experimental/__init__.py +2 -0
  9. mesa/experimental/cell_space/__init__.py +14 -1
  10. mesa/experimental/cell_space/cell.py +84 -23
  11. mesa/experimental/cell_space/cell_agent.py +117 -21
  12. mesa/experimental/cell_space/cell_collection.py +54 -17
  13. mesa/experimental/cell_space/discrete_space.py +79 -7
  14. mesa/experimental/cell_space/grid.py +19 -8
  15. mesa/experimental/cell_space/network.py +9 -7
  16. mesa/experimental/cell_space/voronoi.py +26 -33
  17. mesa/experimental/components/altair.py +10 -0
  18. mesa/experimental/components/matplotlib.py +18 -0
  19. mesa/experimental/devs/__init__.py +2 -0
  20. mesa/experimental/devs/eventlist.py +36 -15
  21. mesa/experimental/devs/examples/epstein_civil_violence.py +65 -29
  22. mesa/experimental/devs/examples/wolf_sheep.py +40 -35
  23. mesa/experimental/devs/simulator.py +55 -15
  24. mesa/experimental/solara_viz.py +10 -19
  25. mesa/main.py +6 -4
  26. mesa/model.py +51 -54
  27. mesa/space.py +145 -120
  28. mesa/time.py +57 -67
  29. mesa/visualization/UserParam.py +19 -6
  30. mesa/visualization/__init__.py +3 -2
  31. mesa/visualization/components/altair.py +4 -2
  32. mesa/visualization/components/matplotlib.py +176 -85
  33. mesa/visualization/solara_viz.py +167 -84
  34. mesa/visualization/utils.py +3 -1
  35. {mesa-3.0.0a4.dist-info → mesa-3.0.0b0.dist-info}/METADATA +55 -13
  36. mesa-3.0.0b0.dist-info/RECORD +45 -0
  37. mesa-3.0.0b0.dist-info/licenses/LICENSE +202 -0
  38. mesa-3.0.0a4.dist-info/licenses/LICENSE → mesa-3.0.0b0.dist-info/licenses/NOTICE +2 -2
  39. mesa-3.0.0a4.dist-info/RECORD +0 -44
  40. {mesa-3.0.0a4.dist-info → mesa-3.0.0b0.dist-info}/WHEEL +0 -0
  41. {mesa-3.0.0a4.dist-info → mesa-3.0.0b0.dist-info}/entry_points.txt +0 -0
mesa/datacollection.py CHANGED
@@ -1,20 +1,19 @@
1
- """
2
- Mesa Data Collection Module
3
- ===========================
1
+ """Mesa Data Collection Module.
4
2
 
5
3
  DataCollector is meant to provide a simple, standard way to collect data
6
- generated by a Mesa model. It collects three types of data: model-level data,
7
- agent-level data, and tables.
4
+ generated by a Mesa model. It collects four types of data: model-level data,
5
+ agent-level data, agent-type-level data, and tables.
8
6
 
9
- A DataCollector is instantiated with two dictionaries of reporter names and
10
- associated variable names or functions for each, one for model-level data and
11
- one for agent-level data; a third dictionary provides table names and columns.
12
- Variable names are converted into functions which retrieve attributes of that
13
- name.
7
+ A DataCollector is instantiated with three dictionaries of reporter names and
8
+ associated variable names or functions for each, one for model-level data,
9
+ one for agent-level data, and one for agent-type-level data; a fourth dictionary
10
+ provides table names and columns. Variable names are converted into functions
11
+ which retrieve attributes of that name.
14
12
 
15
13
  When the collect() method is called, each model-level function is called, with
16
14
  the model as the argument, and the results associated with the relevant
17
- variable. Then the agent-level functions are called on each agent.
15
+ variable. Then the agent-level functions are called on each agent, and the
16
+ agent-type-level functions are called on each agent of the specified type.
18
17
 
19
18
  Additionally, other objects can write directly to tables by passing in an
20
19
  appropriate dictionary object for a table row.
@@ -23,19 +22,18 @@ The DataCollector then stores the data it collects in dictionaries:
23
22
  * model_vars maps each reporter to a list of its values
24
23
  * tables maps each table to a dictionary, with each column as a key with a
25
24
  list as its value.
26
- * _agent_records maps each model step to a list of each agents id
25
+ * _agent_records maps each model step to a list of each agent's id
27
26
  and its values.
27
+ * _agenttype_records maps each model step to a dictionary of agent types,
28
+ each containing a list of each agent's id and its values.
28
29
 
29
30
  Finally, DataCollector can create a pandas DataFrame from each collection.
30
-
31
- The default DataCollector here makes several assumptions:
32
- * The model has an agent list called agents
33
- * For collecting agent-level variables, agents must have a unique_id
34
31
  """
35
32
 
36
33
  import contextlib
37
34
  import itertools
38
35
  import types
36
+ import warnings
39
37
  from copy import deepcopy
40
38
  from functools import partial
41
39
 
@@ -46,24 +44,25 @@ with contextlib.suppress(ImportError):
46
44
  class DataCollector:
47
45
  """Class for collecting data generated by a Mesa model.
48
46
 
49
- A DataCollector is instantiated with dictionaries of names of model- and
50
- agent-level variables to collect, associated with attribute names or
51
- functions which actually collect them. When the collect(...) method is
52
- called, it collects these attributes and executes these functions one by
53
- one and stores the results.
47
+ A DataCollector is instantiated with dictionaries of names of model-,
48
+ agent-, and agent-type-level variables to collect, associated with
49
+ attribute names or functions which actually collect them. When the
50
+ collect(...) method is called, it collects these attributes and executes
51
+ these functions one by one and stores the results.
54
52
  """
55
53
 
56
54
  def __init__(
57
55
  self,
58
56
  model_reporters=None,
59
57
  agent_reporters=None,
58
+ agenttype_reporters=None,
60
59
  tables=None,
61
60
  ):
62
- """
63
- Instantiate a DataCollector with lists of model and agent reporters.
64
- Both model_reporters and agent_reporters accept a dictionary mapping a
65
- variable name to either an attribute name, a function, a method of a class/instance,
66
- or a function with parameters placed in a list.
61
+ """Instantiate a DataCollector with lists of model, agent, and agent-type reporters.
62
+
63
+ Both model_reporters, agent_reporters, and agenttype_reporters accept a
64
+ dictionary mapping a variable name to either an attribute name, a function,
65
+ a method of a class/instance, or a function with parameters placed in a list.
67
66
 
68
67
  Model reporters can take four types of arguments:
69
68
  1. Lambda function:
@@ -87,6 +86,10 @@ class DataCollector:
87
86
  4. Functions with parameters placed in a list:
88
87
  {"Agent_Function": [function, [param_1, param_2]]}
89
88
 
89
+ Agenttype reporters take a dictionary mapping agent types to dictionaries
90
+ of reporter names and attributes/funcs/methods, similar to agent_reporters:
91
+ {Wolf: {"energy": lambda a: a.energy}}
92
+
90
93
  The tables arg accepts a dictionary mapping names of tables to lists of
91
94
  columns. For example, if we want to allow agents to write their age
92
95
  when they are destroyed (to keep track of lifespans), it might look
@@ -96,6 +99,8 @@ class DataCollector:
96
99
  Args:
97
100
  model_reporters: Dictionary of reporter names and attributes/funcs/methods.
98
101
  agent_reporters: Dictionary of reporter names and attributes/funcs/methods.
102
+ agenttype_reporters: Dictionary of agent types to dictionaries of
103
+ reporter names and attributes/funcs/methods.
99
104
  tables: Dictionary of table names to lists of column names.
100
105
 
101
106
  Notes:
@@ -105,9 +110,11 @@ class DataCollector:
105
110
  """
106
111
  self.model_reporters = {}
107
112
  self.agent_reporters = {}
113
+ self.agenttype_reporters = {}
108
114
 
109
115
  self.model_vars = {}
110
116
  self._agent_records = {}
117
+ self._agenttype_records = {}
111
118
  self.tables = {}
112
119
 
113
120
  if model_reporters is not None:
@@ -118,6 +125,11 @@ class DataCollector:
118
125
  for name, reporter in agent_reporters.items():
119
126
  self._new_agent_reporter(name, reporter)
120
127
 
128
+ if agenttype_reporters is not None:
129
+ for agent_type, reporters in agenttype_reporters.items():
130
+ for name, reporter in reporters.items():
131
+ self._new_agenttype_reporter(agent_type, name, reporter)
132
+
121
133
  if tables is not None:
122
134
  for name, columns in tables.items():
123
135
  self._new_table(name, columns)
@@ -165,6 +177,38 @@ class DataCollector:
165
177
 
166
178
  self.agent_reporters[name] = reporter
167
179
 
180
+ def _new_agenttype_reporter(self, agent_type, name, reporter):
181
+ """Add a new agent-type-level reporter to collect.
182
+
183
+ Args:
184
+ agent_type: The type of agent to collect data for.
185
+ name: Name of the agent-type-level variable to collect.
186
+ reporter: Attribute string, function object, method of a class/instance, or
187
+ function with parameters placed in a list that returns the
188
+ variable when given an agent instance.
189
+ """
190
+ if agent_type not in self.agenttype_reporters:
191
+ self.agenttype_reporters[agent_type] = {}
192
+
193
+ # Use the same logic as _new_agent_reporter
194
+ if isinstance(reporter, str):
195
+ attribute_name = reporter
196
+
197
+ def attr_reporter(agent):
198
+ return getattr(agent, attribute_name, None)
199
+
200
+ reporter = attr_reporter
201
+
202
+ elif isinstance(reporter, list):
203
+ func, params = reporter[0], reporter[1]
204
+
205
+ def func_with_params(agent):
206
+ return func(agent, *params)
207
+
208
+ reporter = func_with_params
209
+
210
+ self.agenttype_reporters[agent_type][name] = reporter
211
+
168
212
  def _new_table(self, table_name, table_columns):
169
213
  """Add a new table that objects can write to.
170
214
 
@@ -192,6 +236,34 @@ class DataCollector:
192
236
  )
193
237
  return agent_records
194
238
 
239
+ def _record_agenttype(self, model, agent_type):
240
+ """Record agent-type data in a mapping of functions and agents."""
241
+ rep_funcs = self.agenttype_reporters[agent_type].values()
242
+
243
+ def get_reports(agent):
244
+ _prefix = (agent.model.steps, agent.unique_id)
245
+ reports = tuple(rep(agent) for rep in rep_funcs)
246
+ return _prefix + reports
247
+
248
+ agent_types = model.agent_types
249
+ if agent_type in agent_types:
250
+ agents = model.agents_by_type[agent_type]
251
+ else:
252
+ from mesa import Agent
253
+
254
+ if issubclass(agent_type, Agent):
255
+ agents = [
256
+ agent for agent in model.agents if isinstance(agent, agent_type)
257
+ ]
258
+ else:
259
+ # Raise error if agent_type is not in model.agent_types
260
+ raise ValueError(
261
+ f"Agent type {agent_type} is not recognized as an Agent type in the model or Agent subclass. Use an Agent (sub)class, like {agent_types}."
262
+ )
263
+
264
+ agenttype_records = map(get_reports, agents)
265
+ return agenttype_records
266
+
195
267
  def collect(self, model):
196
268
  """Collect all the data for the given model object."""
197
269
  if self.model_reporters:
@@ -210,7 +282,6 @@ class DataCollector:
210
282
  elif isinstance(reporter, list):
211
283
  self.model_vars[var].append(deepcopy(reporter[0](*reporter[1])))
212
284
  # Assume it's a callable otherwise (e.g., method)
213
- # TODO: Check if method of a class explicitly
214
285
  else:
215
286
  self.model_vars[var].append(deepcopy(reporter()))
216
287
 
@@ -218,6 +289,14 @@ class DataCollector:
218
289
  agent_records = self._record_agents(model)
219
290
  self._agent_records[model.steps] = list(agent_records)
220
291
 
292
+ if self.agenttype_reporters:
293
+ self._agenttype_records[model.steps] = {}
294
+ for agent_type in self.agenttype_reporters:
295
+ agenttype_records = self._record_agenttype(model, agent_type)
296
+ self._agenttype_records[model.steps][agent_type] = list(
297
+ agenttype_records
298
+ )
299
+
221
300
  def add_table_row(self, table_name, row, ignore_missing=False):
222
301
  """Add a row dictionary to a specific table.
223
302
 
@@ -274,6 +353,38 @@ class DataCollector:
274
353
  )
275
354
  return df
276
355
 
356
+ def get_agenttype_vars_dataframe(self, agent_type):
357
+ """Create a pandas DataFrame from the agent-type variables for a specific agent type.
358
+
359
+ The DataFrame has one column for each variable, with two additional
360
+ columns for tick and agent_id.
361
+
362
+ Args:
363
+ agent_type: The type of agent to get the data for.
364
+ """
365
+ # Check if self.agenttype_reporters dictionary is empty for this agent type, if so return empty DataFrame
366
+ if agent_type not in self.agenttype_reporters:
367
+ warnings.warn(
368
+ f"No agent-type reporters have been defined for {agent_type} in the DataCollector, returning empty DataFrame.",
369
+ UserWarning,
370
+ stacklevel=2,
371
+ )
372
+ return pd.DataFrame()
373
+
374
+ all_records = itertools.chain.from_iterable(
375
+ records[agent_type]
376
+ for records in self._agenttype_records.values()
377
+ if agent_type in records
378
+ )
379
+ rep_names = list(self.agenttype_reporters[agent_type])
380
+
381
+ df = pd.DataFrame.from_records(
382
+ data=all_records,
383
+ columns=["Step", "AgentID", *rep_names],
384
+ index=["Step", "AgentID"],
385
+ )
386
+ return df
387
+
277
388
  def get_table_dataframe(self, table_name):
278
389
  """Create a pandas DataFrame from a particular table.
279
390
 
@@ -1,7 +1,10 @@
1
- class UserParam:
1
+ """helper classes."""
2
+
3
+
4
+ class UserParam: # noqa: D101
2
5
  _ERROR_MESSAGE = "Missing or malformed inputs for '{}' Option '{}'"
3
6
 
4
- def maybe_raise_error(self, param_type, valid):
7
+ def maybe_raise_error(self, param_type, valid): # noqa: D102
5
8
  if valid:
6
9
  return
7
10
  msg = self._ERROR_MESSAGE.format(param_type, self.label)
@@ -9,11 +12,9 @@ class UserParam:
9
12
 
10
13
 
11
14
  class Slider(UserParam):
12
- """
13
- A number-based slider input with settable increment.
15
+ """A number-based slider input with settable increment.
14
16
 
15
17
  Example:
16
-
17
18
  slider_option = Slider("My Slider", value=123, min=10, max=200, step=0.1)
18
19
 
19
20
  Args:
@@ -34,6 +35,16 @@ class Slider(UserParam):
34
35
  step=1,
35
36
  dtype=None,
36
37
  ):
38
+ """Slider class.
39
+
40
+ Args:
41
+ label: The displayed label in the UI
42
+ value: The initial value of the slider
43
+ min: The minimum possible value of the slider
44
+ max: The maximum possible value of the slider
45
+ step: The step between min and max for a range of possible values
46
+ dtype: either int or float
47
+ """
37
48
  self.label = label
38
49
  self.value = value
39
50
  self.min = min
@@ -52,5 +63,5 @@ class Slider(UserParam):
52
63
  def _check_values_are_float(self, value, min, max, step):
53
64
  return any(isinstance(n, float) for n in (value, min, max, step))
54
65
 
55
- def get(self, attr):
66
+ def get(self, attr): # noqa: D102
56
67
  return getattr(self, attr)
@@ -1,3 +1,5 @@
1
+ """Experimental init."""
2
+
1
3
  from mesa.experimental import cell_space
2
4
 
3
5
  from .solara_viz import JupyterViz, Slider, SolaraViz, make_text
@@ -1,5 +1,16 @@
1
+ """Cell spaces.
2
+
3
+ Cell spaces offer an alternative API for discrete spaces. It is experimental and under development. The API is more
4
+ expressive that the default grids available in `mesa.space`.
5
+
6
+ """
7
+
1
8
  from mesa.experimental.cell_space.cell import Cell
2
- from mesa.experimental.cell_space.cell_agent import CellAgent
9
+ from mesa.experimental.cell_space.cell_agent import (
10
+ CellAgent,
11
+ FixedAgent,
12
+ Grid2DMovingAgent,
13
+ )
3
14
  from mesa.experimental.cell_space.cell_collection import CellCollection
4
15
  from mesa.experimental.cell_space.discrete_space import DiscreteSpace
5
16
  from mesa.experimental.cell_space.grid import (
@@ -15,6 +26,8 @@ __all__ = [
15
26
  "CellCollection",
16
27
  "Cell",
17
28
  "CellAgent",
29
+ "Grid2DMovingAgent",
30
+ "FixedAgent",
18
31
  "DiscreteSpace",
19
32
  "Grid",
20
33
  "HexGrid",
@@ -1,13 +1,20 @@
1
+ """The Cell in a cell space."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
- from functools import cache
5
+ from collections.abc import Callable
6
+ from functools import cache, cached_property
4
7
  from random import Random
5
- from typing import TYPE_CHECKING
8
+ from typing import TYPE_CHECKING, Any
6
9
 
10
+ from mesa.experimental.cell_space.cell_agent import CellAgent
7
11
  from mesa.experimental.cell_space.cell_collection import CellCollection
12
+ from mesa.space import PropertyLayer
8
13
 
9
14
  if TYPE_CHECKING:
10
- from mesa.experimental.cell_space.cell_agent import CellAgent
15
+ from mesa.agent import Agent
16
+
17
+ Coordinate = tuple[int, ...]
11
18
 
12
19
 
13
20
  class Cell:
@@ -24,11 +31,13 @@ class Cell:
24
31
 
25
32
  __slots__ = [
26
33
  "coordinate",
27
- "_connections",
34
+ "connections",
28
35
  "agents",
29
36
  "capacity",
30
37
  "properties",
31
38
  "random",
39
+ "_mesa_property_layers",
40
+ "__dict__",
32
41
  ]
33
42
 
34
43
  # def __new__(cls,
@@ -42,34 +51,40 @@ class Cell:
42
51
 
43
52
  def __init__(
44
53
  self,
45
- coordinate: tuple[int, ...],
46
- capacity: float | None = None,
54
+ coordinate: Coordinate,
55
+ capacity: int | None = None,
47
56
  random: Random | None = None,
48
57
  ) -> None:
49
- """ "
58
+ """Initialise the cell.
50
59
 
51
60
  Args:
52
- coordinate:
61
+ coordinate: coordinates of the cell
53
62
  capacity (int) : the capacity of the cell. If None, the capacity is infinite
54
63
  random (Random) : the random number generator to use
55
64
 
56
65
  """
57
66
  super().__init__()
58
67
  self.coordinate = coordinate
59
- self._connections: list[Cell] = [] # TODO: change to CellCollection?
60
- self.agents = [] # TODO:: change to AgentSet or weakrefs? (neither is very performant, )
61
- self.capacity = capacity
62
- self.properties: dict[str, object] = {}
68
+ self.connections: dict[Coordinate, Cell] = {}
69
+ self.agents: list[
70
+ Agent
71
+ ] = [] # TODO:: change to AgentSet or weakrefs? (neither is very performant, )
72
+ self.capacity: int | None = capacity
73
+ self.properties: dict[Coordinate, object] = {}
63
74
  self.random = random
75
+ self._mesa_property_layers: dict[str, PropertyLayer] = {}
64
76
 
65
- def connect(self, other: Cell) -> None:
77
+ def connect(self, other: Cell, key: Coordinate | None = None) -> None:
66
78
  """Connects this cell to another cell.
67
79
 
68
80
  Args:
69
81
  other (Cell): other cell to connect to
82
+ key (Tuple[int, ...]): key for the connection. Should resemble a relative coordinate
70
83
 
71
84
  """
72
- self._connections.append(other)
85
+ if key is None:
86
+ key = other.coordinate
87
+ self.connections[key] = other
73
88
 
74
89
  def disconnect(self, other: Cell) -> None:
75
90
  """Disconnects this cell from another cell.
@@ -78,7 +93,9 @@ class Cell:
78
93
  other (Cell): other cell to remove from connections
79
94
 
80
95
  """
81
- self._connections.remove(other)
96
+ keys_to_remove = [k for k, v in self.connections.items() if v == other]
97
+ for key in keys_to_remove:
98
+ del self.connections[key]
82
99
 
83
100
  def add_agent(self, agent: CellAgent) -> None:
84
101
  """Adds an agent to the cell.
@@ -104,7 +121,6 @@ class Cell:
104
121
 
105
122
  """
106
123
  self.agents.remove(agent)
107
- agent.cell = None
108
124
 
109
125
  @property
110
126
  def is_empty(self) -> bool:
@@ -116,37 +132,82 @@ class Cell:
116
132
  """Returns a bool of the contents of a cell."""
117
133
  return len(self.agents) == self.capacity
118
134
 
119
- def __repr__(self):
135
+ def __repr__(self): # noqa
120
136
  return f"Cell({self.coordinate}, {self.agents})"
121
137
 
138
+ @cached_property
139
+ def neighborhood(self) -> CellCollection[Cell]:
140
+ """Returns the direct neighborhood of the cell.
141
+
142
+ This is equivalent to cell.get_neighborhood(radius=1)
143
+
144
+ """
145
+ return self.get_neighborhood()
146
+
122
147
  # FIXME: Revisit caching strategy on methods
123
148
  @cache # noqa: B019
124
- def neighborhood(self, radius=1, include_center=False):
125
- return CellCollection(
149
+ def get_neighborhood(
150
+ self, radius: int = 1, include_center: bool = False
151
+ ) -> CellCollection[Cell]:
152
+ """Returns a list of all neighboring cells for the given radius.
153
+
154
+ For getting the direct neighborhood (i.e., radius=1) you can also use
155
+ the `neighborhood` property.
156
+
157
+ Args:
158
+ radius (int): the radius of the neighborhood
159
+ include_center (bool): include the center of the neighborhood
160
+
161
+ Returns:
162
+ a list of all neighboring cells
163
+
164
+ """
165
+ return CellCollection[Cell](
126
166
  self._neighborhood(radius=radius, include_center=include_center),
127
167
  random=self.random,
128
168
  )
129
169
 
130
170
  # FIXME: Revisit caching strategy on methods
131
171
  @cache # noqa: B019
132
- def _neighborhood(self, radius=1, include_center=False):
172
+ def _neighborhood(
173
+ self, radius: int = 1, include_center: bool = False
174
+ ) -> dict[Cell, list[Agent]]:
133
175
  # if radius == 0:
134
176
  # return {self: self.agents}
135
177
  if radius < 1:
136
178
  raise ValueError("radius must be larger than one")
137
179
  if radius == 1:
138
- neighborhood = {neighbor: neighbor.agents for neighbor in self._connections}
180
+ neighborhood = {
181
+ neighbor: neighbor.agents for neighbor in self.connections.values()
182
+ }
139
183
  if not include_center:
140
184
  return neighborhood
141
185
  else:
142
186
  neighborhood[self] = self.agents
143
187
  return neighborhood
144
188
  else:
145
- neighborhood = {}
146
- for neighbor in self._connections:
189
+ neighborhood: dict[Cell, list[Agent]] = {}
190
+ for neighbor in self.connections.values():
147
191
  neighborhood.update(
148
192
  neighbor._neighborhood(radius - 1, include_center=True)
149
193
  )
150
194
  if not include_center:
151
195
  neighborhood.pop(self, None)
152
196
  return neighborhood
197
+
198
+ # PropertyLayer methods
199
+ def get_property(self, property_name: str) -> Any:
200
+ """Get the value of a property."""
201
+ return self._mesa_property_layers[property_name].data[self.coordinate]
202
+
203
+ def set_property(self, property_name: str, value: Any):
204
+ """Set the value of a property."""
205
+ self._mesa_property_layers[property_name].set_cell(self.coordinate, value)
206
+
207
+ def modify_property(
208
+ self, property_name: str, operation: Callable, value: Any = None
209
+ ):
210
+ """Modify the value of a property."""
211
+ self._mesa_property_layers[property_name].modify_cell(
212
+ self.coordinate, operation, value
213
+ )