Mesa 3.0.0__py3-none-any.whl → 3.0.0a0__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 (104) hide show
  1. mesa/__init__.py +3 -3
  2. mesa/agent.py +114 -406
  3. mesa/batchrunner.py +27 -54
  4. mesa/cookiecutter-mesa/cookiecutter.json +8 -0
  5. mesa/cookiecutter-mesa/hooks/post_gen_project.py +11 -0
  6. mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +4 -0
  7. mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +27 -0
  8. mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +11 -0
  9. mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +60 -0
  10. mesa/datacollection.py +29 -140
  11. mesa/experimental/__init__.py +1 -11
  12. mesa/experimental/cell_space/__init__.py +1 -16
  13. mesa/experimental/cell_space/cell.py +23 -93
  14. mesa/experimental/cell_space/cell_agent.py +21 -117
  15. mesa/experimental/cell_space/cell_collection.py +17 -54
  16. mesa/experimental/cell_space/discrete_space.py +8 -92
  17. mesa/experimental/cell_space/grid.py +8 -32
  18. mesa/experimental/cell_space/network.py +7 -12
  19. mesa/experimental/devs/__init__.py +0 -2
  20. mesa/experimental/devs/eventlist.py +14 -52
  21. mesa/experimental/devs/examples/epstein_civil_violence.py +39 -71
  22. mesa/experimental/devs/examples/wolf_sheep.py +45 -45
  23. mesa/experimental/devs/simulator.py +15 -55
  24. mesa/main.py +63 -0
  25. mesa/model.py +83 -211
  26. mesa/space.py +149 -215
  27. mesa/time.py +77 -62
  28. mesa/{experimental → visualization}/UserParam.py +6 -17
  29. mesa/visualization/__init__.py +2 -25
  30. mesa/{experimental → visualization}/components/altair.py +0 -10
  31. mesa/visualization/components/matplotlib.py +134 -0
  32. mesa/{experimental/solara_viz.py → visualization/jupyter_viz.py} +110 -65
  33. {mesa-3.0.0.dist-info → mesa-3.0.0a0.dist-info}/METADATA +13 -65
  34. mesa-3.0.0a0.dist-info/RECORD +38 -0
  35. mesa-3.0.0.dist-info/licenses/NOTICE → mesa-3.0.0a0.dist-info/licenses/LICENSE +2 -2
  36. mesa/examples/README.md +0 -37
  37. mesa/examples/__init__.py +0 -21
  38. mesa/examples/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb +0 -116
  39. mesa/examples/advanced/epstein_civil_violence/Readme.md +0 -34
  40. mesa/examples/advanced/epstein_civil_violence/__init__.py +0 -0
  41. mesa/examples/advanced/epstein_civil_violence/agents.py +0 -164
  42. mesa/examples/advanced/epstein_civil_violence/app.py +0 -73
  43. mesa/examples/advanced/epstein_civil_violence/model.py +0 -114
  44. mesa/examples/advanced/pd_grid/Readme.md +0 -43
  45. mesa/examples/advanced/pd_grid/__init__.py +0 -0
  46. mesa/examples/advanced/pd_grid/agents.py +0 -50
  47. mesa/examples/advanced/pd_grid/analysis.ipynb +0 -228
  48. mesa/examples/advanced/pd_grid/app.py +0 -54
  49. mesa/examples/advanced/pd_grid/model.py +0 -71
  50. mesa/examples/advanced/sugarscape_g1mt/Readme.md +0 -64
  51. mesa/examples/advanced/sugarscape_g1mt/__init__.py +0 -0
  52. mesa/examples/advanced/sugarscape_g1mt/agents.py +0 -344
  53. mesa/examples/advanced/sugarscape_g1mt/app.py +0 -62
  54. mesa/examples/advanced/sugarscape_g1mt/model.py +0 -180
  55. mesa/examples/advanced/sugarscape_g1mt/sugar-map.txt +0 -50
  56. mesa/examples/advanced/sugarscape_g1mt/tests.py +0 -69
  57. mesa/examples/advanced/wolf_sheep/Readme.md +0 -57
  58. mesa/examples/advanced/wolf_sheep/__init__.py +0 -0
  59. mesa/examples/advanced/wolf_sheep/agents.py +0 -102
  60. mesa/examples/advanced/wolf_sheep/app.py +0 -84
  61. mesa/examples/advanced/wolf_sheep/model.py +0 -137
  62. mesa/examples/basic/__init__.py +0 -0
  63. mesa/examples/basic/boid_flockers/Readme.md +0 -22
  64. mesa/examples/basic/boid_flockers/__init__.py +0 -0
  65. mesa/examples/basic/boid_flockers/agents.py +0 -71
  66. mesa/examples/basic/boid_flockers/app.py +0 -58
  67. mesa/examples/basic/boid_flockers/model.py +0 -69
  68. mesa/examples/basic/boltzmann_wealth_model/Readme.md +0 -56
  69. mesa/examples/basic/boltzmann_wealth_model/__init__.py +0 -0
  70. mesa/examples/basic/boltzmann_wealth_model/agents.py +0 -31
  71. mesa/examples/basic/boltzmann_wealth_model/app.py +0 -74
  72. mesa/examples/basic/boltzmann_wealth_model/model.py +0 -43
  73. mesa/examples/basic/boltzmann_wealth_model/st_app.py +0 -115
  74. mesa/examples/basic/conways_game_of_life/Readme.md +0 -39
  75. mesa/examples/basic/conways_game_of_life/__init__.py +0 -0
  76. mesa/examples/basic/conways_game_of_life/agents.py +0 -47
  77. mesa/examples/basic/conways_game_of_life/app.py +0 -51
  78. mesa/examples/basic/conways_game_of_life/model.py +0 -31
  79. mesa/examples/basic/conways_game_of_life/st_app.py +0 -72
  80. mesa/examples/basic/schelling/Readme.md +0 -40
  81. mesa/examples/basic/schelling/__init__.py +0 -0
  82. mesa/examples/basic/schelling/agents.py +0 -26
  83. mesa/examples/basic/schelling/analysis.ipynb +0 -205
  84. mesa/examples/basic/schelling/app.py +0 -42
  85. mesa/examples/basic/schelling/model.py +0 -59
  86. mesa/examples/basic/virus_on_network/Readme.md +0 -61
  87. mesa/examples/basic/virus_on_network/__init__.py +0 -0
  88. mesa/examples/basic/virus_on_network/agents.py +0 -69
  89. mesa/examples/basic/virus_on_network/app.py +0 -114
  90. mesa/examples/basic/virus_on_network/model.py +0 -96
  91. mesa/experimental/cell_space/voronoi.py +0 -257
  92. mesa/experimental/components/matplotlib.py +0 -242
  93. mesa/visualization/components/__init__.py +0 -83
  94. mesa/visualization/components/altair_components.py +0 -188
  95. mesa/visualization/components/matplotlib_components.py +0 -175
  96. mesa/visualization/mpl_space_drawing.py +0 -593
  97. mesa/visualization/solara_viz.py +0 -458
  98. mesa/visualization/user_param.py +0 -69
  99. mesa/visualization/utils.py +0 -9
  100. mesa-3.0.0.dist-info/RECORD +0 -95
  101. mesa-3.0.0.dist-info/licenses/LICENSE +0 -202
  102. /mesa/{examples/advanced → cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}}/__init__.py +0 -0
  103. {mesa-3.0.0.dist-info → mesa-3.0.0a0.dist-info}/WHEEL +0 -0
  104. {mesa-3.0.0.dist-info → mesa-3.0.0a0.dist-info}/entry_points.txt +0 -0
@@ -1,458 +0,0 @@
1
- """Mesa visualization module for creating interactive model visualizations.
2
-
3
- This module provides components to create browser- and Jupyter notebook-based visualizations of
4
- Mesa models, allowing users to watch models run step-by-step and interact with model parameters.
5
-
6
- Key features:
7
- - SolaraViz: Main component for creating visualizations, supporting grid displays and plots
8
- - ModelController: Handles model execution controls (step, play, pause, reset)
9
- - UserInputs: Generates UI elements for adjusting model parameters
10
-
11
- The module uses Solara for rendering in Jupyter notebooks or as standalone web applications.
12
- It supports various types of visualizations including matplotlib plots, agent grids, and
13
- custom visualization components.
14
-
15
- Usage:
16
- 1. Define an agent_portrayal function to specify how agents should be displayed
17
- 2. Set up model_params to define adjustable parameters
18
- 3. Create a SolaraViz instance with your model, parameters, and desired measures
19
- 4. Display the visualization in a Jupyter notebook or run as a Solara app
20
-
21
- See the Visualization Tutorial and example models for more details.
22
- """
23
-
24
- from __future__ import annotations
25
-
26
- import asyncio
27
- import inspect
28
- from collections.abc import Callable
29
- from typing import TYPE_CHECKING, Literal
30
-
31
- import reacton.core
32
- import solara
33
-
34
- import mesa.visualization.components.altair_components as components_altair
35
- from mesa.visualization.user_param import Slider
36
- from mesa.visualization.utils import force_update, update_counter
37
-
38
- if TYPE_CHECKING:
39
- from mesa.model import Model
40
-
41
-
42
- @solara.component
43
- def SolaraViz(
44
- model: Model | solara.Reactive[Model],
45
- components: list[reacton.core.Component]
46
- | list[Callable[[Model], reacton.core.Component]]
47
- | Literal["default"] = "default",
48
- play_interval: int = 100,
49
- model_params=None,
50
- name: str | None = None,
51
- ):
52
- """Solara visualization component.
53
-
54
- This component provides a visualization interface for a given model using Solara.
55
- It supports various visualization components and allows for interactive model
56
- stepping and parameter adjustments.
57
-
58
- Args:
59
- model (Model | solara.Reactive[Model]): A Model instance or a reactive Model.
60
- This is the main model to be visualized. If a non-reactive model is provided,
61
- it will be converted to a reactive model.
62
- components (list[solara.component] | Literal["default"], optional): List of solara
63
- components or functions that return a solara component.
64
- These components are used to render different parts of the model visualization.
65
- Defaults to "default", which uses the default Altair space visualization.
66
- play_interval (int, optional): Interval for playing the model steps in milliseconds.
67
- This controls the speed of the model's automatic stepping. Defaults to 100 ms.
68
- model_params (dict, optional): Parameters for (re-)instantiating a model.
69
- Can include user-adjustable parameters and fixed parameters. Defaults to None.
70
- name (str | None, optional): Name of the visualization. Defaults to the models class name.
71
-
72
- Returns:
73
- solara.component: A Solara component that renders the visualization interface for the model.
74
-
75
- Example:
76
- >>> model = MyModel()
77
- >>> page = SolaraViz(model)
78
- >>> page
79
-
80
- Notes:
81
- - The `model` argument can be either a direct model instance or a reactive model. If a direct
82
- model instance is provided, it will be converted to a reactive model using `solara.use_reactive`.
83
- - The `play_interval` argument controls the speed of the model's automatic stepping. A lower
84
- value results in faster stepping, while a higher value results in slower stepping.
85
- """
86
- if components == "default":
87
- components = [components_altair.make_altair_space()]
88
- if model_params is None:
89
- model_params = {}
90
-
91
- # Convert model to reactive
92
- if not isinstance(model, solara.Reactive):
93
- model = solara.use_reactive(model) # noqa: SH102, RUF100
94
-
95
- def connect_to_model():
96
- # Patch the step function to force updates
97
- original_step = model.value.step
98
-
99
- def step():
100
- original_step()
101
- force_update()
102
-
103
- model.value.step = step
104
- # Add a trigger to model itself
105
- model.value.force_update = force_update
106
- force_update()
107
-
108
- solara.use_effect(connect_to_model, [model.value])
109
-
110
- # set up reactive model_parameters shared by ModelCreator and ModelController
111
- reactive_model_parameters = solara.use_reactive({})
112
-
113
- with solara.AppBar():
114
- solara.AppBarTitle(name if name else model.value.__class__.__name__)
115
-
116
- with solara.Sidebar(), solara.Column():
117
- with solara.Card("Controls"):
118
- ModelController(
119
- model,
120
- model_parameters=reactive_model_parameters,
121
- play_interval=play_interval,
122
- )
123
- with solara.Card("Model Parameters"):
124
- ModelCreator(
125
- model, model_params, model_parameters=reactive_model_parameters
126
- )
127
- with solara.Card("Information"):
128
- ShowSteps(model.value)
129
-
130
- ComponentsView(components, model.value)
131
-
132
-
133
- def _wrap_component(
134
- component: reacton.core.Component | Callable[[Model], reacton.core.Component],
135
- ) -> reacton.core.Component:
136
- """Wrap a component in an auto-updated Solara component if needed."""
137
- if isinstance(component, reacton.core.Component):
138
- return component
139
-
140
- @solara.component
141
- def WrappedComponent(model):
142
- update_counter.get()
143
- return component(model)
144
-
145
- return WrappedComponent
146
-
147
-
148
- @solara.component
149
- def ComponentsView(
150
- components: list[reacton.core.Component]
151
- | list[Callable[[Model], reacton.core.Component]],
152
- model: Model,
153
- ):
154
- """Display a list of components.
155
-
156
- Args:
157
- components: List of components to display
158
- model: Model instance to pass to each component
159
- """
160
- wrapped_components = [_wrap_component(component) for component in components]
161
- items = [component(model) for component in wrapped_components]
162
- grid_layout_initial = make_initial_grid_layout(num_components=len(items))
163
- grid_layout, set_grid_layout = solara.use_state(grid_layout_initial)
164
- solara.GridDraggable(
165
- items=items,
166
- grid_layout=grid_layout,
167
- resizable=True,
168
- draggable=True,
169
- on_grid_layout=set_grid_layout,
170
- )
171
-
172
-
173
- JupyterViz = SolaraViz
174
-
175
-
176
- @solara.component
177
- def ModelController(
178
- model: solara.Reactive[Model],
179
- *,
180
- model_parameters: dict | solara.Reactive[dict] = None,
181
- play_interval: int = 100,
182
- ):
183
- """Create controls for model execution (step, play, pause, reset).
184
-
185
- Args:
186
- model: Reactive model instance
187
- model_parameters: Reactive parameters for (re-)instantiating a model.
188
- play_interval: Interval for playing the model steps in milliseconds.
189
-
190
- """
191
- playing = solara.use_reactive(False)
192
- running = solara.use_reactive(True)
193
- if model_parameters is None:
194
- model_parameters = {}
195
- model_parameters = solara.use_reactive(model_parameters)
196
-
197
- async def step():
198
- while playing.value and running.value:
199
- await asyncio.sleep(play_interval / 1000)
200
- do_step()
201
-
202
- solara.lab.use_task(
203
- step, dependencies=[playing.value, running.value], prefer_threaded=False
204
- )
205
-
206
- def do_step():
207
- """Advance the model by one step."""
208
- model.value.step()
209
- running.value = model.value.running
210
-
211
- def do_reset():
212
- """Reset the model to its initial state."""
213
- playing.value = False
214
- running.value = True
215
- model.value = model.value = model.value.__class__(**model_parameters.value)
216
-
217
- def do_play_pause():
218
- """Toggle play/pause."""
219
- playing.value = not playing.value
220
-
221
- with solara.Row(justify="space-between"):
222
- solara.Button(label="Reset", color="primary", on_click=do_reset)
223
- solara.Button(
224
- label="▶" if not playing.value else "❚❚",
225
- color="primary",
226
- on_click=do_play_pause,
227
- disabled=not running.value,
228
- )
229
- solara.Button(
230
- label="Step",
231
- color="primary",
232
- on_click=do_step,
233
- disabled=playing.value or not running.value,
234
- )
235
-
236
-
237
- def split_model_params(model_params):
238
- """Split model parameters into user-adjustable and fixed parameters.
239
-
240
- Args:
241
- model_params: Dictionary of all model parameters
242
-
243
- Returns:
244
- tuple: (user_adjustable_params, fixed_params)
245
- """
246
- model_params_input = {}
247
- model_params_fixed = {}
248
- for k, v in model_params.items():
249
- if check_param_is_fixed(v):
250
- model_params_fixed[k] = v
251
- else:
252
- model_params_input[k] = v
253
- return model_params_input, model_params_fixed
254
-
255
-
256
- def check_param_is_fixed(param):
257
- """Check if a parameter is fixed (not user-adjustable).
258
-
259
- Args:
260
- param: Parameter to check
261
-
262
- Returns:
263
- bool: True if parameter is fixed, False otherwise
264
- """
265
- if isinstance(param, Slider):
266
- return False
267
- if not isinstance(param, dict):
268
- return True
269
- if "type" not in param:
270
- return True
271
-
272
-
273
- @solara.component
274
- def ModelCreator(
275
- model: solara.Reactive[Model],
276
- user_params: dict,
277
- *,
278
- model_parameters: dict | solara.Reactive[dict] = None,
279
- ):
280
- """Solara component for creating and managing a model instance with user-defined parameters.
281
-
282
- This component allows users to create a model instance with specified parameters and seed.
283
- It provides an interface for adjusting model parameters and reseeding the model's random
284
- number generator.
285
-
286
- Args:
287
- model: A reactive model instance. This is the main model to be created and managed.
288
- user_params: Parameters for (re-)instantiating a model. Can include user-adjustable parameters and fixed parameters. Defaults to None.
289
- model_parameters: reactive parameters for reinitializing the model
290
-
291
- Returns:
292
- solara.component: A Solara component that renders the model creation and management interface.
293
-
294
- Example:
295
- >>> model = solara.reactive(MyModel())
296
- >>> model_params = {
297
- >>> "param1": {"type": "slider", "value": 10, "min": 0, "max": 100},
298
- >>> "param2": {"type": "slider", "value": 5, "min": 1, "max": 10},
299
- >>> }
300
- >>> creator = ModelCreator(model, model_params)
301
- >>> creator
302
-
303
- Notes:
304
- - The `model_params` argument should be a dictionary where keys are parameter names and values either fixed values
305
- or are dictionaries containing parameter details such as type, value, min, and max.
306
- - The `seed` argument ensures reproducibility by setting the initial seed for the model's random number generator.
307
- - The component provides an interface for adjusting user-defined parameters and reseeding the model.
308
-
309
- """
310
- if model_parameters is None:
311
- model_parameters = {}
312
- model_parameters = solara.use_reactive(model_parameters)
313
-
314
- solara.use_effect(
315
- lambda: _check_model_params(model.value.__class__.__init__, fixed_params),
316
- [model.value],
317
- )
318
- user_params, fixed_params = split_model_params(user_params)
319
-
320
- # set model_parameters to the default values for all parameters
321
- model_parameters.value = {
322
- **fixed_params,
323
- **{k: v.get("value") for k, v in user_params.items()},
324
- }
325
-
326
- def on_change(name, value):
327
- new_model_parameters = {**model_parameters.value, name: value}
328
- model.value = model.value.__class__(**new_model_parameters)
329
- model_parameters.value = new_model_parameters
330
-
331
- UserInputs(user_params, on_change=on_change)
332
-
333
-
334
- def _check_model_params(init_func, model_params):
335
- """Check if model parameters are valid for the model's initialization function.
336
-
337
- Args:
338
- init_func: Model initialization function
339
- model_params: Dictionary of model parameters
340
-
341
- Raises:
342
- ValueError: If a parameter is not valid for the model's initialization function
343
- """
344
- model_parameters = inspect.signature(init_func).parameters
345
- for name in model_parameters:
346
- if (
347
- model_parameters[name].default == inspect.Parameter.empty
348
- and name not in model_params
349
- and name != "self"
350
- and name != "kwargs"
351
- ):
352
- raise ValueError(f"Missing required model parameter: {name}")
353
- for name in model_params:
354
- if name not in model_parameters and "kwargs" not in model_parameters:
355
- raise ValueError(f"Invalid model parameter: {name}")
356
-
357
-
358
- @solara.component
359
- def UserInputs(user_params, on_change=None):
360
- """Initialize user inputs for configurable model parameters.
361
-
362
- Currently supports :class:`solara.SliderInt`, :class:`solara.SliderFloat`,
363
- :class:`solara.Select`, and :class:`solara.Checkbox`.
364
-
365
- Args:
366
- user_params: Dictionary with options for the input, including label, min and max values, and other fields specific to the input type.
367
- on_change: Function to be called with (name, value) when the value of an input changes.
368
- """
369
- for name, options in user_params.items():
370
-
371
- def change_handler(value, name=name):
372
- on_change(name, value)
373
-
374
- if isinstance(options, Slider):
375
- slider_class = (
376
- solara.SliderFloat if options.is_float_slider else solara.SliderInt
377
- )
378
- slider_class(
379
- options.label,
380
- value=options.value,
381
- on_value=change_handler,
382
- min=options.min,
383
- max=options.max,
384
- step=options.step,
385
- )
386
- continue
387
-
388
- # label for the input is "label" from options or name
389
- label = options.get("label", name)
390
- input_type = options.get("type")
391
- if input_type == "SliderInt":
392
- solara.SliderInt(
393
- label,
394
- value=options.get("value"),
395
- on_value=change_handler,
396
- min=options.get("min"),
397
- max=options.get("max"),
398
- step=options.get("step"),
399
- )
400
- elif input_type == "SliderFloat":
401
- solara.SliderFloat(
402
- label,
403
- value=options.get("value"),
404
- on_value=change_handler,
405
- min=options.get("min"),
406
- max=options.get("max"),
407
- step=options.get("step"),
408
- )
409
- elif input_type == "Select":
410
- solara.Select(
411
- label,
412
- value=options.get("value"),
413
- on_value=change_handler,
414
- values=options.get("values"),
415
- )
416
- elif input_type == "Checkbox":
417
- solara.Checkbox(
418
- label=label,
419
- on_value=change_handler,
420
- value=options.get("value"),
421
- )
422
- elif input_type == "InputText":
423
- solara.InputText(
424
- label=label,
425
- on_value=change_handler,
426
- value=options.get("value"),
427
- )
428
- else:
429
- raise ValueError(f"{input_type} is not a supported input type")
430
-
431
-
432
- def make_initial_grid_layout(num_components):
433
- """Create an initial grid layout for visualization components.
434
-
435
- Args:
436
- num_components: Number of components to display
437
-
438
- Returns:
439
- list: Initial grid layout configuration
440
- """
441
- return [
442
- {
443
- "i": i,
444
- "w": 6,
445
- "h": 10,
446
- "moved": False,
447
- "x": 6 * (i % 2),
448
- "y": 16 * (i - i % 2),
449
- }
450
- for i in range(num_components)
451
- ]
452
-
453
-
454
- @solara.component
455
- def ShowSteps(model):
456
- """Display the current step of the model."""
457
- update_counter.get()
458
- return solara.Text(f"Step: {model.steps}")
@@ -1,69 +0,0 @@
1
- """Solara visualization related helper classes."""
2
-
3
-
4
- class UserParam:
5
- """UserParam."""
6
-
7
- _ERROR_MESSAGE = "Missing or malformed inputs for '{}' Option '{}'"
8
-
9
- def maybe_raise_error(self, param_type, valid): # noqa: D102
10
- if valid:
11
- return
12
- msg = self._ERROR_MESSAGE.format(param_type, self.label)
13
- raise ValueError(msg)
14
-
15
-
16
- class Slider(UserParam):
17
- """A number-based slider input with settable increment.
18
-
19
- Example:
20
- slider_option = Slider("My Slider", value=123, min=10, max=200, step=0.1)
21
-
22
- Args:
23
- label: The displayed label in the UI
24
- value: The initial value of the slider
25
- min: The minimum possible value of the slider
26
- max: The maximum possible value of the slider
27
- step: The step between min and max for a range of possible values
28
- dtype: either int or float
29
- """
30
-
31
- def __init__(
32
- self,
33
- label="",
34
- value=None,
35
- min=None,
36
- max=None,
37
- step=1,
38
- dtype=None,
39
- ):
40
- """Initializes a slider.
41
-
42
- Args:
43
- label: The displayed label in the UI
44
- value: The initial value of the slider
45
- min: The minimum possible value of the slider
46
- max: The maximum possible value of the slider
47
- step: The step between min and max for a range of possible values
48
- dtype: either int or float
49
- """
50
- self.label = label
51
- self.value = value
52
- self.min = min
53
- self.max = max
54
- self.step = step
55
-
56
- # Validate option type to make sure values are supplied properly
57
- valid = not (self.value is None or self.min is None or self.max is None)
58
- self.maybe_raise_error("slider", valid)
59
-
60
- if dtype is None:
61
- self.is_float_slider = self._check_values_are_float(value, min, max, step)
62
- else:
63
- self.is_float_slider = dtype is float
64
-
65
- def _check_values_are_float(self, value, min, max, step): # D103
66
- return any(isinstance(n, float) for n in (value, min, max, step))
67
-
68
- def get(self, attr): # noqa: D102
69
- return getattr(self, attr)
@@ -1,9 +0,0 @@
1
- """Solara related utils."""
2
-
3
- import solara
4
-
5
- update_counter = solara.reactive(0)
6
-
7
-
8
- def force_update(): # noqa: D103
9
- update_counter.value += 1
@@ -1,95 +0,0 @@
1
- mesa/__init__.py,sha256=bdkU9L2v5WZiXXPkTYYoPcEfsdgX_Mu-VzvAvwVUSiM,657
2
- mesa/agent.py,sha256=Ein1Ei7n1wZNKcv4L1NlP3iPu9q1pm-QGIL64dLC5Fw,24636
3
- mesa/batchrunner.py,sha256=sMFLTxj5avP_-HGO0leLVuxXK2dH0xdPopvhAmawwRQ,7213
4
- mesa/datacollection.py,sha256=xyb07aBpd-HSDh5bk-XcVqGiDu5bfaLlxj5eDlGIwqY,16138
5
- mesa/model.py,sha256=fojtI87UxDLnRB71CGUKbZWh0BrstBHoCU9xWcw-MsA,10406
6
- mesa/space.py,sha256=cfzlRfy9chegp8d89k2aqI29jo9cb18USlz2G2iOZU4,64082
7
- mesa/time.py,sha256=5yWubqst13MfjXpsYjY-MNdIQH3KWi373KRmRZT5BBo,15044
8
- mesa/examples/README.md,sha256=dNn8kv0BNQem3NNhO5mbOANQoK8UUYOo7rnkCFV9tnE,2882
9
- mesa/examples/__init__.py,sha256=iJpTRiCJUwLVA253t5BIxoX3bFnPJ2_XPzET3ev5mxg,835
10
- mesa/examples/advanced/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- mesa/examples/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb,sha256=yh50ZAK2BVJyJIKsQTTxywnasqWn1IiQUVrwmZKue4w,29032
12
- mesa/examples/advanced/epstein_civil_violence/Readme.md,sha256=IEU5IZTe5EbvAA2vkYxiIw8vK3O0MZcjbxzn8I2cQic,1874
13
- mesa/examples/advanced/epstein_civil_violence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- mesa/examples/advanced/epstein_civil_violence/agents.py,sha256=0X4JLj2K2cl1bACkFLI6-K6tKbr2SLZlAy_kjgUDjzA,5863
15
- mesa/examples/advanced/epstein_civil_violence/app.py,sha256=puJmjkEevHyilfDpnkE65Y2ax6JEyOALg-IEtK8jBKk,1787
16
- mesa/examples/advanced/epstein_civil_violence/model.py,sha256=fcTkjCRhEhDerDC1W_lrezdoWD1y5xIublkGIhCak8w,3918
17
- mesa/examples/advanced/pd_grid/Readme.md,sha256=UVUQxZRFdfymCKDdQEn3ZEwgSqgp9cKJPsU8oZpLFnY,2367
18
- mesa/examples/advanced/pd_grid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- mesa/examples/advanced/pd_grid/agents.py,sha256=DzGj4LZUjV0xMQAwkRsv2Aoap1cUvLscJswfA1PdVDs,1716
20
- mesa/examples/advanced/pd_grid/analysis.ipynb,sha256=ReYtRe2JVyCCXoMBONvynXDQ_eGtQSWhNcuJY3CYTTI,82323
21
- mesa/examples/advanced/pd_grid/app.py,sha256=u8dnB3cXkTENU26O1XN3REFTxEwvXLFLD3EybgVQWP0,1354
22
- mesa/examples/advanced/pd_grid/model.py,sha256=iKy1Oa5lG_hlxwlw67NfFLP9dKk5uDreaaT0xO9-55A,2325
23
- mesa/examples/advanced/sugarscape_g1mt/Readme.md,sha256=x3kKw1Rre2FPkNhGDLtdzeThmH089mxsGYUPZUeu26k,3595
24
- mesa/examples/advanced/sugarscape_g1mt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- mesa/examples/advanced/sugarscape_g1mt/agents.py,sha256=zE7zbO2_OaQiFDq_-t-0hv4ButBWv26dnS1zaPc3_ZE,10183
26
- mesa/examples/advanced/sugarscape_g1mt/app.py,sha256=PYuHoAH4AfU8fbrkBpY-ZW8evwz5izLEP8srN1CHp_Y,1946
27
- mesa/examples/advanced/sugarscape_g1mt/model.py,sha256=VVoUni3N2yk7vLEcWC1hiQemaa1vmzJU3gKxVRXxnqM,6069
28
- mesa/examples/advanced/sugarscape_g1mt/sugar-map.txt,sha256=zZtGYciBPT4miZVnbVuoQ5TugTmGrbDWV9yb5KH6tnU,5000
29
- mesa/examples/advanced/sugarscape_g1mt/tests.py,sha256=UNahmZTgLquSqmoi_9GcE3JP0qBHjkrHFZ15NMm0ce8,2517
30
- mesa/examples/advanced/wolf_sheep/Readme.md,sha256=6zrtCg4Fb-hgQxqdLMpTkIYMwD6owCv8BMz_qn0N98Q,3165
31
- mesa/examples/advanced/wolf_sheep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- mesa/examples/advanced/wolf_sheep/agents.py,sha256=UocDCsKmXkWxt0-ToVIOhBjX-amYwMtZbHN8U2AolFI,3068
33
- mesa/examples/advanced/wolf_sheep/app.py,sha256=n-WIPMHPYRvqrnsEF7y7mTLN5XKxKB3rJhQZzXZHwo8,2210
34
- mesa/examples/advanced/wolf_sheep/model.py,sha256=qtCTA2fBP9lA7jJ8UUJ5SIy8gXW7K73YoY8F3YDKp6k,4522
35
- mesa/examples/basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- mesa/examples/basic/boid_flockers/Readme.md,sha256=4KJinsLPtUciQSMzvaX3tU5r1HTUg3AFOFDKy73W5RE,894
37
- mesa/examples/basic/boid_flockers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- mesa/examples/basic/boid_flockers/agents.py,sha256=QXT1zxOq_kdk_w60H2zPV3KpivzCHQ-ApyFIIDvxvok,2693
39
- mesa/examples/basic/boid_flockers/app.py,sha256=5wKzyctjTq3iX1MJc69l3753a_iyYhFq3kv54h7dGSE,1289
40
- mesa/examples/basic/boid_flockers/model.py,sha256=o335lgyGQ1E5TkAj4B-INhUL65mO0dEV3tf3gG40FvU,2201
41
- mesa/examples/basic/boltzmann_wealth_model/Readme.md,sha256=wl1ylO9KWoTiuIJKOnk2FGdcmyVUqJ5wiSbVUa3WWAc,2725
42
- mesa/examples/basic/boltzmann_wealth_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- mesa/examples/basic/boltzmann_wealth_model/agents.py,sha256=uVUo9jWQnv5I3uCaYE_N7X-cOdHhdy6RtLUL_znELgI,892
44
- mesa/examples/basic/boltzmann_wealth_model/app.py,sha256=kc39j71OeKKWIs7MGzuUrbTkaIpjjZDWXC9K0dQIrow,2170
45
- mesa/examples/basic/boltzmann_wealth_model/model.py,sha256=BYcfR5Nw0zXkKP72CoVnLkIvV-IVnNKKNQ7KsbJ07pc,1508
46
- mesa/examples/basic/boltzmann_wealth_model/st_app.py,sha256=v3Je2hSe8nXPgfmZhX8lHM-7xs8dk2g1Zz0X81AqX3k,3466
47
- mesa/examples/basic/conways_game_of_life/Readme.md,sha256=VRgN6roF6leQ_IMYwxFypSfFjZo9jnCd-rkPTjpp7II,1453
48
- mesa/examples/basic/conways_game_of_life/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- mesa/examples/basic/conways_game_of_life/agents.py,sha256=ETn87GV8it9p0nlSn6f1qu5CDEmqokkr6Rq7KWaT-5U,1627
50
- mesa/examples/basic/conways_game_of_life/app.py,sha256=DrA1CwiT43rDMZGSDO62B77_QymySkq486IeV9K8nJY,1433
51
- mesa/examples/basic/conways_game_of_life/model.py,sha256=c7lwSelxTplbQlbfGjBSevS2TEg5DFJA8bvhbYbyD_s,1174
52
- mesa/examples/basic/conways_game_of_life/st_app.py,sha256=_poqU2VR4rfiiq4WFXTbOUSW7liuM86iq913mW6LS50,2400
53
- mesa/examples/basic/schelling/Readme.md,sha256=CRKBfYtnLJLlTKLsTRQ-7gsQRxVxDooOBN5uP8PEtaU,2296
54
- mesa/examples/basic/schelling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- mesa/examples/basic/schelling/agents.py,sha256=dvznzN2As979x-4EH8Y-i7HhlCuv1OdtWYebOdxTdhk,773
56
- mesa/examples/basic/schelling/analysis.ipynb,sha256=JDJy6-U6eO-LrHWxZr1c3lkvtoY0DNHa-kJ4J-Z-wwo,5804
57
- mesa/examples/basic/schelling/app.py,sha256=DlePd3iTkBSzurRy1vbZXlAugpxcEMFFR5Iy6b9RWp8,973
58
- mesa/examples/basic/schelling/model.py,sha256=szYiw76JD-OMlZ2Op80Y9L2PZ3VMVfyuUNl1J_jC8BE,1856
59
- mesa/examples/basic/virus_on_network/Readme.md,sha256=UnCkKiJK7wVw40a-oDR6qdf3QpCsBhgNOVZg-2UXPlc,2528
60
- mesa/examples/basic/virus_on_network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
- mesa/examples/basic/virus_on_network/agents.py,sha256=a_WhqYblJlW6od67eXfU-nb7IMRyYpgxtf0le--VYoA,1975
62
- mesa/examples/basic/virus_on_network/app.py,sha256=Bxjm2FHxnbjQd3V1absTM4GDOrWOlOYZtYMn3Yy0Ol8,2439
63
- mesa/examples/basic/virus_on_network/model.py,sha256=jQoCmvygwCvhUrlL0l7V8GcDLv94CgwtuK7DDGU8q8g,2813
64
- mesa/experimental/UserParam.py,sha256=f32nmFjroe76HpxU75ZCEOqFW2nAsDfmqIf8kQ1zt-E,2086
65
- mesa/experimental/__init__.py,sha256=faBYyHSp-sFQPaBx8-WsLToVKCndpSzpt18HmNZtasM,385
66
- mesa/experimental/solara_viz.py,sha256=uWrNQAX3oEWSftmyjNorN839dBCUp86hnhpL704dyGQ,15212
67
- mesa/experimental/cell_space/__init__.py,sha256=-NtSCT7mA-aszLSAdqbICGqeFe2vBdb-GrcW562legY,999
68
- mesa/experimental/cell_space/cell.py,sha256=lDm7NQhPDFf3-SZu5W594lDNGtzcdSPUSSsELFRg0bs,7166
69
- mesa/experimental/cell_space/cell_agent.py,sha256=jvYOV9OIaBaqAsAG0YLV64X_f3BJe_wP7qfos_RXi0Y,3759
70
- mesa/experimental/cell_space/cell_collection.py,sha256=ZcyuPEevCZEXW7jFnX6StjBMw4UBDQvUspZRcFi2dFg,3426
71
- mesa/experimental/cell_space/discrete_space.py,sha256=sD5455phlIthnAK6OsgxVscQ4C_HSVWA9e476C3PuF0,5264
72
- mesa/experimental/cell_space/grid.py,sha256=oWTy6kaaHXLPneA-w5XdqzwA0YItMWYgCq_UjNH9iA8,7711
73
- mesa/experimental/cell_space/network.py,sha256=_x0zKlI-odNCSRb_Zqh4nBPjqnW5iVj8sVheKPCLzmU,1321
74
- mesa/experimental/cell_space/voronoi.py,sha256=lSY8zQhELvOy0RfDyZIek09UMwY9_20UY9SPqFWsNoM,10014
75
- mesa/experimental/components/altair.py,sha256=49OHgrm1JncfrKqDfw_5ifPtsbMKdgVYCacL9SMwucc,2624
76
- mesa/experimental/components/matplotlib.py,sha256=j477UBk_7yW5vzT3rjhnuTixpA7PedDNghoK9TLgHVY,8043
77
- mesa/experimental/devs/__init__.py,sha256=EByaC66ikUIu9G9p1geLm6ESEMWZOPTO9r9627S83j0,211
78
- mesa/experimental/devs/eventlist.py,sha256=fPj2jfW-jTe-UnIE6TsF1BM2ITKe3jGfVUhu3gBv7UQ,6250
79
- mesa/experimental/devs/simulator.py,sha256=wvqkLIDgbJNaem9nwMacyEYRp0W3ai5Oxptw3-QmbSw,10595
80
- mesa/experimental/devs/examples/epstein_civil_violence.py,sha256=E8YSV3O5ihKsntGtnltHM-4IyS8eg2DSRUqmIiw_1iU,10916
81
- mesa/experimental/devs/examples/wolf_sheep.py,sha256=1eb1CfYNQoprqSJat-LPYPvwWH1ENQdj39viEqwSk0s,8103
82
- mesa/visualization/__init__.py,sha256=o30F2VApnDJ6Zq0_U5_wBnj-6-Bu7FGPsOq3A6p2EqA,743
83
- mesa/visualization/mpl_space_drawing.py,sha256=yf3Sc7pm5EJLxfWQdtR-9PcUtZveEEjar1WUr7qwI4o,20057
84
- mesa/visualization/solara_viz.py,sha256=6RKtbXWEZbGK2kKeN2QmoH3xByiv_1vV5JdehI_OWqs,15935
85
- mesa/visualization/user_param.py,sha256=Dl2WOwLYLf0pfLpabCZtIdFRyKZrK6Qtc3utZx5GPYg,2139
86
- mesa/visualization/utils.py,sha256=lJHgRKF5BHLf72Tw3YpwyiWuRoIimaTKQ7xBCw_Rx3A,146
87
- mesa/visualization/components/__init__.py,sha256=Bq3nrPikcaIo9BSs0O3zptWVLlUmAkLo3s0mEmpH1RE,3022
88
- mesa/visualization/components/altair_components.py,sha256=wotpFFQgMY-ZR3lNVm_fRos-iDg0Wjnj6Tk67_7f1SQ,5847
89
- mesa/visualization/components/matplotlib_components.py,sha256=xQETaFyHIfmL_9JwrLIgubuIQ7-pp7TMoXT1WMmozus,5441
90
- mesa-3.0.0.dist-info/METADATA,sha256=ePOHoMKU7ItQxPSPlAkvVg578ToQQEo0d4qUfQ69rzU,9842
91
- mesa-3.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
92
- mesa-3.0.0.dist-info/entry_points.txt,sha256=IOcQtetGF8l4wHpOs_hGb19Rz-FS__BMXOJR10IBPsA,39
93
- mesa-3.0.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
94
- mesa-3.0.0.dist-info/licenses/NOTICE,sha256=GbsWoK0QWv1JyZ_xer2s-jNilv0RtWl-0UrtlJANHPg,578
95
- mesa-3.0.0.dist-info/RECORD,,