Repository navigation
Fix unpickling of continuous spaces - #4108
Merged
Merged
Conversation
Unpickling a ContinuousSpace turned agent_positions into an independent array instead of a view on the backing array. Positions written through agents then went only to the copy, and were lost as soon as an agent was added or removed and the view was taken again. Take the view again in __setstate__. Assisted-by: Claude Opus 5.5
Member
Author
|
I split this off from #3940 on the (fair) request of the bot (probably should have done it earlier). This makes #3940 smaller, atomic and thus a bit easier to review. This PR itself is also very small. @quaquel @codebreaker32 could you review? |
|
Performance benchmarks:
|
EwoutH
added a commit
that referenced
this pull request
Nov 22, 2026
Unpickling a ContinuousSpace turned agent_positions into an independent array instead of a view on the backing array. Positions written through agents then went only to the copy, and were lost as soon as an agent was added or removed and the view was taken again. Take the view again in __setstate__. (cherry picked from commit 28e4136)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-PR Checklist
Summary
An unpickled
ContinuousSpacedetachedagent_positionsfrom its backing array, so an agent's moves were lost as soon as another agent was added or removed.Bug / Issue
Unpickling a
ContinuousSpaceturnedagent_positionsinto an independent array instead of a view on the backing array. Positions written through agents then went only to the copy, and were lost as soon as an agent was added or removed and the view was taken again. This came up in #3939. TheGridpickling bug found at the same time was fixed in #3914.Implementation
Take the view again in
ContinuousSpace.__setstate__.Testing
test_pickled_space_keeps_position_viewfails without the fix and passes with it.Additional Notes
Split from #3940, which is stacked on this PR. Written with help from Claude Code (Claude Opus 5.5).