Skip to content

Commit aa839b9

Browse files
authored
Add module-level docstring to experimental features (#2532)
* Extend DEVS module-level docstring * Extend Observables module-level docstring * Extend Cell Space module-level docstring * Add Experimental module-level docstring
1 parent 712c4ad commit aa839b9

File tree

18 files changed

+241
-24
lines changed

18 files changed

+241
-24
lines changed

.codespellignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ ue
77
fpr
88
falsy
99
assertIn
10+
nD

mesa/experimental/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
"""Experimental init."""
1+
"""Experimental features package for Mesa.
2+
3+
This package contains modules that are under active development and testing. These
4+
features are provided to allow early access and feedback from the Mesa community, but
5+
their APIs may change between releases without following semantic versioning.
6+
7+
Current experimental modules:
8+
cell_space: Alternative API for discrete spaces with cell-centric functionality
9+
devs: Discrete event simulation system for scheduling events at arbitrary times
10+
mesa_signals: Reactive programming capabilities for tracking state changes
11+
12+
Notes:
13+
- Features in this package may be changed or removed without notice
14+
- APIs are not guaranteed to be stable between releases
15+
- Features graduate from experimental status once their APIs are stabilized
16+
"""
217

318
from mesa.experimental import cell_space, devs, mesa_signals
419

mesa/experimental/cell_space/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
"""Cell spaces.
1+
"""Cell spaces for active, property-rich spatial modeling in Mesa.
22
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`.
3+
Cell spaces extend Mesa's spatial modeling capabilities by making the space itself active -
4+
each position (cell) can have properties and behaviors rather than just containing agents.
5+
This enables more sophisticated environmental modeling and agent-environment interactions.
56
7+
Key components:
8+
- Cells: Active positions that can have properties and contain agents
9+
- CellAgents: Agents that understand how to interact with cells
10+
- Spaces: Different cell organization patterns (grids, networks, etc.)
11+
- PropertyLayers: Efficient property storage and manipulation
12+
13+
This is particularly useful for models where the environment plays an active role,
14+
like resource growth, pollution diffusion, or infrastructure networks. The cell
15+
space system is experimental and under active development.
616
"""
717

818
from mesa.experimental.cell_space.cell import Cell

mesa/experimental/cell_space/cell.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
"""The Cell in a cell space."""
1+
"""Cells are positions in space that can have properties and contain agents.
2+
3+
A cell represents a location that can:
4+
- Have properties (like temperature or resources)
5+
- Track and limit the agents it contains
6+
- Connect to neighboring cells
7+
- Provide neighborhood information
8+
9+
Cells form the foundation of the cell space system, enabling rich spatial
10+
environments where both location properties and agent behaviors matter. They're
11+
useful for modeling things like varying terrain, infrastructure capacity, or
12+
environmental conditions.
13+
"""
214

315
from __future__ import annotations
416

mesa/experimental/cell_space/cell_agent.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
"""An agent with movement methods for cell spaces."""
1+
"""Agents that understand how to exist in and move through cell spaces.
2+
3+
Provides specialized agent classes that handle cell occupation, movement, and
4+
proper registration:
5+
- CellAgent: Mobile agents that can move between cells
6+
- FixedAgent: Immobile agents permanently fixed to cells
7+
- Grid2DMovingAgent: Agents with grid-specific movement capabilities
8+
9+
These classes ensure consistent agent-cell relationships and proper state management
10+
as agents move through the space. They can be used directly or as examples for
11+
creating custom cell-aware agents.
12+
"""
213

314
from __future__ import annotations
415

mesa/experimental/cell_space/cell_collection.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
"""CellCollection class."""
1+
"""Collection class for managing and querying groups of cells.
2+
3+
The CellCollection class provides a consistent interface for operating on multiple
4+
cells, supporting:
5+
- Filtering and selecting cells based on conditions
6+
- Random cell and agent selection
7+
- Access to contained agents
8+
- Group operations
9+
10+
This is useful for implementing area effects, zones, or any operation that needs
11+
to work with multiple cells as a unit. The collection handles efficient iteration
12+
and agent access across cells. The class is used throughout the cell space
13+
implementation to represent neighborhoods, selections, and other cell groupings.
14+
"""
215

316
from __future__ import annotations
417

mesa/experimental/cell_space/discrete_space.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
"""DiscreteSpace base class."""
1+
"""Base class for building cell-based spatial environments.
2+
3+
DiscreteSpace provides the core functionality needed by all cell-based spaces:
4+
- Cell creation and tracking
5+
- Agent-cell relationship management
6+
- Property layer support
7+
- Random selection capabilities
8+
- Capacity management
9+
10+
This serves as the foundation for specific space implementations like grids
11+
and networks, ensuring consistent behavior and shared functionality across
12+
different space types. All concrete cell space implementations (grids, networks, etc.)
13+
inherit from this class.
14+
"""
215

316
from __future__ import annotations
417

mesa/experimental/cell_space/grid.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
"""Various Grid Spaces."""
1+
"""Grid-based cell space implementations with different connection patterns.
2+
3+
Provides several grid types for organizing cells:
4+
- OrthogonalMooreGrid: 8 neighbors in 2D, (3^n)-1 in nD
5+
- OrthogonalVonNeumannGrid: 4 neighbors in 2D, 2n in nD
6+
- HexGrid: 6 neighbors in hexagonal pattern (2D only)
7+
8+
Each grid type supports optional wrapping (torus) and cell capacity limits.
9+
Choose based on how movement and connectivity should work in your model -
10+
Moore for unrestricted movement, Von Neumann for orthogonal-only movement,
11+
or Hex for more uniform distances.
12+
"""
213

314
from __future__ import annotations
415

mesa/experimental/cell_space/network.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
"""A Network grid."""
1+
"""Network-based cell space using arbitrary connection patterns.
2+
3+
Creates spaces where cells connect based on network relationships rather than
4+
spatial proximity. Built on NetworkX graphs, this enables:
5+
- Arbitrary connectivity patterns between cells
6+
- Graph-based neighborhood definitions
7+
- Logical rather than physical distances
8+
- Dynamic connectivity changes
9+
- Integration with NetworkX's graph algorithms
10+
11+
Useful for modeling systems like social networks, transportation systems,
12+
or any environment where connectivity matters more than physical location.
13+
"""
214

315
from random import Random
416
from typing import Any

mesa/experimental/cell_space/property_layer.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
"""This module provides functionality for working with property layers in grids."""
1+
"""Efficient storage and manipulation of cell properties across spaces.
2+
3+
PropertyLayers provide a way to associate properties with cells in a space efficiently.
4+
The module includes:
5+
- PropertyLayer class for managing grid-wide properties
6+
- Property access descriptors for cells
7+
- Batch operations for property modification
8+
- Property-based cell selection
9+
- Integration with numpy for efficient operations
10+
11+
This system separates property storage from cells themselves, enabling
12+
fast bulk operations and sophisticated property-based behaviors while
13+
maintaining an intuitive interface through cell attributes. Properties
14+
can represent environmental factors, cell states, or any other grid-wide
15+
attributes.
16+
"""
217

318
import warnings
419
from collections.abc import Callable, Sequence

0 commit comments

Comments
 (0)