Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mesa/visualization/mpl_space_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def draw_space(
Returns the Axes object with the plot drawn onto it.
``agent_portrayal`` is called with an agent and should return a AgentPortrayalStyle. Valid fields in this object are "color",
"size", "marker", "zorder", alpha, linewidths, and edgecolors. Other field are ignored and will result in a user warning.
"size", "marker", "zorder", "alpha", "linewidths", and "edgecolors". Other field are ignored and will result in a user warning.
"""
if ax is None:
Expand Down
27 changes: 13 additions & 14 deletions tests/test_components_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
PropertyLayer,
SingleGrid,
)
from mesa.visualization.components import AgentPortrayalStyle
from mesa.visualization.mpl_space_drawing import (
draw_continuous_space,
draw_hex_grid,
Expand All @@ -37,11 +36,11 @@ def agent_portrayal(agent):
agent (Agent): The agent to portray

"""
return AgentPortrayalStyle(
size=10,
color="tab:blue",
marker="s" if (agent.unique_id % 2) == 0 else "o",
)
return {
"size": 10,
"color": "tab:blue",
"marker": "s" if (agent.unique_id % 2) == 0 else "o",
Copy link
Member

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.

Copy link
Contributor Author

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.

}


def test_draw_space():
Expand All @@ -54,14 +53,14 @@ def my_portrayal(agent):
agent (Agent): The agent to portray

"""
return AgentPortrayalStyle(
size=10,
color="tab:blue",
marker="s" if (agent.unique_id % 2) == 0 else "o",
alpha=0.5,
linewidths=1,
edgecolors="tab:orange",
)
return {
"size": 10,
"color": "tab:blue",
"marker": "s" if (agent.unique_id % 2) == 0 else "o",
"alpha": 0.5,
"linewidths": 1,
"edgecolors": "tab:orange",
}

# draw space for hexgrid
model = Model(seed=42)
Expand Down
Loading