Support AgentPortrayalStyle in Altair visualization components#2985
Merged
Support AgentPortrayalStyle in Altair visualization components#2985
Conversation
…l_space_drawer Update agent_portrayal in test_call_space_drawer to use AgentPortrayalStyle instead of dict
Add _portrayal_to_dict() helper to convert AgentPortrayalStyle to dict format for Altair charts. Update tests to use new portrayal API.
332f99e to
a3a3e51
Compare
|
Performance benchmarks:
|
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.
Problem
The Altair visualization components (
altair_components.py) were not updated to support the newAgentPortrayalStyleclass introduced in the visualization refactoring. When users returned anAgentPortrayalStyleinstance from theiragent_portrayalfunction, the code attempted dictionary-style assignment (agent_data["x"] = x), causing aTypeError: 'AgentPortrayalStyle' object does not support item assignment.This also triggered a deprecation warning in tests that were still using the old dict-based portrayal format.
Changes
_portrayal_to_dict()helper function to convertAgentPortrayalStyleinstances to dict format for Altair chart generation_get_agent_data_old__discrete_space(),_get_agent_data_new_discrete_space(), and_get_agent_data_continuous_space()to use the helper functiontest_call_space_drawerto useAgentPortrayalStyleinstead of deprecated dict formatTechnical Details
Altair requires dict-formatted data for chart generation and only uses
colorandsizefields from the agent portrayal (other fields become tooltips). The helper function extracts these fields fromAgentPortrayalStyleinstances while preserving the original dict-based behavior for legacy code.Follow-up on #2786.