Skip to content

Commit d62ef3e

Browse files
committed
first set of tests
1 parent 7aec942 commit d62ef3e

File tree

6 files changed

+151
-202
lines changed

6 files changed

+151
-202
lines changed

mesa/experimental/cell_space/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from mesa.experimental.cell_space.network import Network
2323
from mesa.experimental.cell_space.voronoi import VoronoiGrid
24+
from mesa.experimental.cell_space.property_layer import PropertyLayer
2425

2526
__all__ = [
2627
"CellCollection",
@@ -35,4 +36,5 @@
3536
"OrthogonalVonNeumannGrid",
3637
"Network",
3738
"VoronoiGrid",
39+
"PropertyLayer"
3840
]

mesa/experimental/cell_space/cell.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from mesa.experimental.cell_space.cell_agent import CellAgent
1111
from mesa.experimental.cell_space.cell_collection import CellCollection
12-
from mesa.space import PropertyLayer
1312

1413
if TYPE_CHECKING:
1514
from mesa.agent import Agent
@@ -24,7 +23,6 @@ class Cell:
2423
coordinate (Tuple[int, int]) : the position of the cell in the discrete space
2524
agents (List[Agent]): the agents occupying the cell
2625
capacity (int): the maximum number of agents that can simultaneously occupy the cell
27-
properties (dict[str, Any]): the properties of the cell
2826
random (Random): the random number generator
2927
3028
"""
@@ -34,21 +32,10 @@ class Cell:
3432
"connections",
3533
"agents",
3634
"capacity",
37-
"properties",
3835
"random",
39-
"_mesa_property_layers",
4036
"__dict__",
4137
]
4238

43-
# def __new__(cls,
44-
# coordinate: tuple[int, ...],
45-
# capacity: float | None = None,
46-
# random: Random | None = None,):
47-
# if capacity != 1:
48-
# return object.__new__(cls)
49-
# else:
50-
# return object.__new__(SingleAgentCell)
51-
5239
def __init__(
5340
self,
5441
coordinate: Coordinate,
@@ -69,10 +56,9 @@ def __init__(
6956
self.agents: list[
7057
Agent
7158
] = [] # TODO:: change to AgentSet or weakrefs? (neither is very performant, )
59+
self.properties = {} # fixme still used by voronoi mesh
7260
self.capacity: int | None = capacity
73-
self.properties: dict[Coordinate, object] = {}
7461
self.random = random
75-
self._mesa_property_layers: dict[str, PropertyLayer] = {}
7662

7763
def connect(self, other: Cell, key: Coordinate | None = None) -> None:
7864
"""Connects this cell to another cell.

mesa/experimental/cell_space/discrete_space.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
from __future__ import annotations
44

55
import warnings
6-
from collections.abc import Callable
76
from functools import cached_property
87
from random import Random
9-
from typing import Any, Generic, TypeVar
8+
from typing import Generic, TypeVar
109

1110
from mesa.agent import AgentSet
1211
from mesa.experimental.cell_space.cell import Cell
1312
from mesa.experimental.cell_space.cell_collection import CellCollection
14-
from mesa.space import PropertyLayer
1513

1614
T = TypeVar("T", bound=Cell)
1715

mesa/experimental/cell_space/grid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
from typing import Generic, TypeVar
99

1010
from mesa.experimental.cell_space import Cell, DiscreteSpace
11+
from mesa.experimental.cell_space.property_layer import HasPropertyLayers
1112

1213
T = TypeVar("T", bound=Cell)
1314

1415

15-
class Grid(DiscreteSpace[T], Generic[T]):
16+
class Grid(DiscreteSpace[T], Generic[T], HasPropertyLayers):
1617
"""Base class for all grid classes.
1718
1819
Attributes:

0 commit comments

Comments
 (0)