Update GIS example models for Cell API changes
Problem
Three GIS example models in Mesa-examples are failing due to breaking changes introduced in https://github.com/mesa/mesa-geo/pull/299, which added new keyword arguments (rowcol, xy) to the Cell.__init__() method.
Failing models:
gis/urban_growth-UrbanCellgis/rainfall-LakeCellgis/population-UgandaCell
Error:
TypeError: <CustomCell>.__init__() got an unexpected keyword argument 'rowcol'
Root cause
The updated Cell.__init__() in mesa-geo now accepts keyword-only arguments rowcol and xy:
def __init__(self, model, pos=None, indices=None, *, rowcol=None, xy=None):
Custom Cell subclasses in the example models don't accept these arguments, causing instantiation to fail when RasterLayer._initialize_cells() tries to create cells.
Additional considerations
While fixing the signatures, we might update the models to use the new cell.rowcol property instead of the deprecated cell.indices where applicable.
Hi, I would like to work on updating the GIS example models to support the new Cell API changes. I have been exploring Mesa internals and would love to take this up. Please let me know if I can proceed.
@EwoutH Hi, I'd like to work on this fix. I'll update the init signatures for UrbanCell, LakeCell, and UgandaCell to accept the new rowcol and xy kwargs.
@EwoutH Hi, I investigated this issue. All three GIS Cell subclasses (UrbanCell, LakeCell, UgandaCell) already use **kwargs in their init signatures and pass them to super().init(), which means they are already compatible with the new rowcol and xy keyword arguments introduced in mesa-geo#299. Tested with mesa-geo 0.9.3 where all models import successfully with no TypeError. Could this issue be closed, or is there a specific version where the bug still reproduces?
Hi @EwoutH, @wang-boyu, and @Harshini2411!
I just pulled down the repository to do a full sweep for the 'Additional considerations' regarding replacing the deprecated cell.indices.
I ran a recursive search across the entire gis/ directory, and I can confirm there is actually zero usage of .indices in any of the example models! The original authors didn't rely on it for their spatial logic.
Combining this with Harshini's great catch about **kwargs already safely absorbing the new rowcol and xy parameters during initialization, these models are completely compatible with Mesa-Geo 0.9.3.
It looks like this issue is fully resolved out-of-the-box and can safely be closed! ✅