-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix Ignored Dict Keys in Agent Portrayal #2918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
tests/test_components_matplotlib.py
Outdated
| return { | ||
| "size": 10, | ||
| "color": "tab:blue", | ||
| "marker": "s" if (agent.unique_id % 2) == 0 else "o", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing stuff backwards right? Using dicts is deprecated, we now use AgentPortrayalStyle objects.
See #2786 and #2872, and our migration guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will look on to it.
This comment was marked as off-topic.
This comment was marked as off-topic.
tests/test_devs.py
Outdated
| # The runtime now emits a FutureWarning for this deprecation. | ||
| # Update test to match the current warning type. | ||
| with pytest.warns(FutureWarning, match="simulator.time is deprecated"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. This was a bit time pressing however, so I already fixed it in #2922.
Summary
Fixed
UserWarnings caused by using incorrect keys (s,c,linecolors) in agent portrayal dictionaries within tests and clarified documentation.Bug / Issue #2904
The issue was that tests/test_components_matplotlib.py was using Matplotlib-style keys (
s,c) in the dictionary returned by agent_portrayal, which are not recognized by Mesa'smpl_space_drawingmodule. This led to multipleUserWarning: The following keys from the returned dict were ignoredmessages during testing. Additionally, the documentation in mpl_space_drawing.py needed consistent formatting for valid keys.Implementation
mpl_space_drawing:"s"with"size"."c"with"color"."linecolors"with"edgecolors"."size","color", etc.) for better readability and accuracy.Testing
pytest tests/test_components_matplotlib.py -W alwaysand verified that theUserWarning: The following keys from the returned dict were ignoredmessages are no longer present.Additional Notes
This ensures that the tests follow the recommended way of defining agent portrayals and keeps the test output clean.