Bugfix for pickling dynamically modified grids#3217
Conversation
| for cell in self._cells.values(): | ||
| connections = { | ||
| coordinate: self._cells[coordinate] | ||
| for coordinate in cell.connections.keys() |
There was a problem hiding this comment.
To fix ruff / pre-commit
| for coordinate in cell.connections.keys() | |
| for coordinate in cell.connections |
There was a problem hiding this comment.
Grid pickling was covered by tests, but not for dynamically modified grids. Theoretically, the grid data structure allows for dynamic modifications. However, because of the caching, which is essential for performance, we did not develop that further into a real API. #3086 was just taking advantage of a version bump on the minimum Python side, so not a bug.
@quaquel Thanks for jumping on this so quickly — it’s great to see this getting fixed. I’d be happy to help add some tests around pickling/unpickling dynamic grids or example models if that would be useful. |
|
Performance benchmarks:
|
This bugfix updates
Cell.__getstate__andGrid.__setstate__to ensure that the actual structure of the grid is properly preserved when pickling a grid.closes #3215