Repository navigation
Fix IndexError in Altair visualization when no agents are present - #3685
Merged
Merged
Conversation
|
Performance benchmarks:
|
Comment on lines
+158
to
+159
| if not all_agent_data: | ||
| return alt.Chart(pd.DataFrame({"x": [], "y": []})).mark_point().properties(width=300, height=300) |
Contributor
There was a problem hiding this comment.
the early return for if not all_agent_data here bypasses the property-layer branch entirely, so empty spaces with a property layer will render as a blank point chart instead of showing the property layer. The existing flow clearly supports property-only rendering via altair_components.py, so returning before that logic is a behavioral regression rather than just a crash fix. In other words, this PR fixes “no agents” only for the no agents + no property layer case.
falloficaruss
approved these changes
Apr 5, 2026
Member
|
Thanks for the PR and the peer review. Appreciated. @Sahil-Chhoker would you be able to review this? |
Sahil-Chhoker
approved these changes
Apr 10, 2026
Sahil-Chhoker
left a comment
Collaborator
There was a problem hiding this comment.
Good work @SiddharthRiot and @falloficarus22, changes look good to me.
EwoutH
pushed a commit
that referenced
this pull request
Oct 28, 2026
) Fixes a crash in the Altair-based space visualization when the model contains no agents. (cherry picked from commit b387075)
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.
Summary
Fixes a crash in the Altair-based space visualization when the model contains no agents.
Bug / Issue
Fixes #3682
When
all_agent_datais empty, the code attempts to accessall_agent_data[0], causing anIndexError: list index out of range.Expected behavior:
Implementation
Added a guard clause in
_draw_grid()to handle the case whereall_agent_datais empty.Testing
Additional Notes
This ensures safer handling of edge cases where no agents exist in the model space and aligns with the expected behavior described in the issue.