Backend array storage: make _data the single source of truth (RasterLayer refactor PR 2) - #332
Backend array storage: make _data the single source of truth (RasterLayer refactor PR 2)#332Tejasv-Singh wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #332 +/- ##
==========================================
+ Coverage 78.32% 78.50% +0.18%
==========================================
Files 10 10
Lines 1024 1033 +9
Branches 168 161 -7
==========================================
+ Hits 802 811 +9
Misses 181 181
Partials 41 41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2b613ff to
677a242
Compare
677a242 to
bdac019
Compare
Backend array storage:
_dataas the single source of truthPart of #328. Follows #330 (merged).
This is PR 2 of the GSoC 2026 RasterLayer refactor. Its scope was narrowed following maintainer feedback:
Cellremains amesa.Agentsubclass in this PR. DecouplingCellfromAgenthas been deferred to a follow-up PR (to land alongside the cell-collection work).What this does
RasterLayer._data(adict[str, np.ndarray]) the single source of truth for all band data.set_band,get_band,remove_band,apply_raster, andget_raster, these now read from and write to_datadirectly instead of scattering/gathering across every cell.Cella thin proxy:__getattr__/__setattr__route band access (cell.<band>) directly intoself._layer._data[name][row, col]. Cells no longer hold per-cell copies of band values.cell._layervia a_layer=kwarg passed in_initialize_cells, preserving exact backward compatibility for both the legacy (pos/indices) and currentCellconstructor signatures.test_agent_init_proxy_pos_interaction) confirming that the proxy safely ignores the default attribute assignments made byAgent.__init__, and thatposstill behaves.grid_posproperty onCellas a preferred replacement for the deprecatedpos(see open question below).Deferred to follow-up PRs
Cellfrommesa.Agent: moved to a separate PR to land with cell collection, so activation isn't split between agents and the collection.urban_growth,rainfall,population) still assign band attributes (self.<band> = None) in__init__before their bands exist. This is handled in a separate mesa-examples PR, per the breaking-change workflow (release → bumprequirements.txt→ update examples).CI notes
Test GIS examplesis expected to fail on this branch. It's the deferred examples regression above, not an accidental break, it'll go green once the mesa-examples PR lands after the next release.Open questions for review
grid_pos: kept here for now, but sinceposdeprecation is conceptually part of the cell redesign, happy to defer it to the decoupling PR if preferred.self.<band> = Nonebefore the band exists will shadow the proxy (the value stays in__dict__). Following the discussion, this is being handled by investigating a migrate-and-erase approach rather than a__getattribute__safety net; noting it here so it's tracked in review..