Skip to content
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

bugfix for draw_property_layer #2639

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Changes from 3 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
7 changes: 3 additions & 4 deletions mesa/visualization/mpl_space_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ def draw_property_layers(
continue

data = layer.data.astype(float) if layer.data.dtype == bool else layer.data
width, height = data.shape # if space is None else (space.width, space.height)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding these two lines:

data = data.T
height, width = data.shape

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed your comments in a slightly different way but the effect is the same

if space and data.shape != (width, height):
if (space.width, space.height) != data.shape:
warnings.warn(
f"Layer {layer_name} dimensions ({data.shape}) do not match space dimensions ({width}, {height}).",
quaquel marked this conversation as resolved.
Show resolved Hide resolved
UserWarning,
quaquel marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -217,7 +216,7 @@ def draw_property_layers(
layer_name, [(0, 0, 0, 0), (*rgba_color[:3], alpha)]
)
im = ax.imshow(
rgba_data,
rgba_data.T,
quaquel marked this conversation as resolved.
Show resolved Hide resolved
origin="lower",
)
if colorbar:
Expand All @@ -231,7 +230,7 @@ def draw_property_layers(
if isinstance(cmap, list):
cmap = LinearSegmentedColormap.from_list(layer_name, cmap)
im = ax.imshow(
data,
data.T,
cmap=cmap,
alpha=alpha,
vmin=vmin,
Expand Down
Loading