-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor Cell.__getstate__ to use modern super() implementation #3084
Copy link
Copy link
Closed
Description
Description
The Cell class in mesa/discrete_space/cell.py currently uses a manual implementation for getstate to handle serialization (pickling). It intentionally clears the connections attribute to avoid infinite recursion during deepcopy operations.
The code currently contains a FIXME indicating this logic was a temporary workaround for older Python versions:
# fixme, once we shift to 3.11, replace this with super. __getstate__Context
The project's pyproject.toml now sets requires-python = ">=3.12", meaning the legacy workaround is no longer necessary.
Task
Refactor the getstate method in mesa/discrete_space/cell.py to:
- Remove the manual dictionary construction.
- Utilize
super().__getstate__()to retrieve the default state. - Ensure the logic that clears the connections dictionary is preserved to prevent recursion errors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels