You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I browsed and tested the source code of Mesa 3.0 and the latest compatible mesa-geo version, and I like the new framework. To provide users with an interface for modification, I hope to create a separate method for setting up cells when refactoring RasterLayer rather than specifying everything in __init__.
Describe the solution you'd like
Specifically, after the Mesa 3.0 version, I tried to directly inherit RasterLayer in my ABSESpy and add my Cell class, but there was no such overridable interface. So I made the following changes to the mesa-geo source code:
def __init__(
self, width, height, crs, total_bounds, model, cell_cls: type[Cell] = Cell
):
super().__init__(width, height, crs, total_bounds)
self.model = model
self.cell_cls = cell_cls
self._setup_cells()
self._attributes = set()
self._neighborhood_cache = {}
def _setup_cells(self) -> None:
self.cells = []
for x in range(self.width):
col: list[self.cell_cls] = []
for y in range(self.height):
row_idx, col_idx = self.height - y - 1, x
col.append(self.cell_cls(self.model, pos=(x,y), indices=(row_idx,col_idx)))
self.cells.append(col)
Additional context
I saw an interesting discussion about refactoring this class in #81. I think it's a good idea, and I will also try to find somewhere to contribute.
The text was updated successfully, but these errors were encountered:
Thanks for your interest in this. Would you like to take a look at the PropertyLayer from Mesa, since RasterLayer are essentially the geo versions of PropertyLayer? I have raised #201 for it. Some of its usages are mentioned in projectmesa/mesa#2440.
SongshGeo
added a commit
to SongshGeo/mesa-geo
that referenced
this issue
Nov 8, 2024
What's the problem this feature will solve?
Hi, long time no see.
I browsed and tested the source code of Mesa 3.0 and the latest compatible mesa-geo version, and I like the new framework. To provide users with an interface for modification, I hope to create a separate method for setting up cells when refactoring
RasterLayer
rather than specifying everything in__init__
.Describe the solution you'd like
Specifically, after the Mesa 3.0 version, I tried to directly inherit RasterLayer in my ABSESpy and add my Cell class, but there was no such overridable interface. So I made the following changes to the mesa-geo source code:
Additional context
I saw an interesting discussion about refactoring this class in #81. I think it's a good idea, and I will also try to find somewhere to contribute.
The text was updated successfully, but these errors were encountered: