Skip to content

Commit

Permalink
refactor: ♻️ seperate cells' initialization into a private method
Browse files Browse the repository at this point in the history
  • Loading branch information
SongshGeo authored and wang-boyu committed Feb 2, 2025
1 parent 61a44df commit 011e9da
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mesa_geo/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ def __init__(
self.model = model
self.cell_cls = cell_cls
self.cells = []
self._initialize_cells(model, cell_cls)
self._attributes = set()
self._neighborhood_cache = {}

def _initialize_cells(self, model: Model, cell_cls: type[Cell]):
for x in range(self.width):
col: list[cell_cls] = []
for y in range(self.height):
row_idx, col_idx = self.height - y - 1, x
col.append(self.cell_cls(model, pos=(x, y), indices=(row_idx, col_idx)))
self.cells.append(col)

self._attributes = set()
self._neighborhood_cache = {}

@property
def attributes(self) -> set[str]:
"""
Expand Down

0 comments on commit 011e9da

Please sign in to comment.