Skip to content

Commit

Permalink
bug fixes for draw_property_layers (#2548)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaquel authored Dec 14, 2024
1 parent 965eede commit f72a268
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 0 additions & 6 deletions mesa/examples/advanced/sugarscape_g1mt/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import os
import sys

sys.path.insert(0, os.path.abspath("../../../.."))


import numpy as np
import solara
from matplotlib.figure import Figure
Expand Down
9 changes: 6 additions & 3 deletions mesa/visualization/mpl_space_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ def draw_property_layers(

for layer_name, portrayal in propertylayer_portrayal.items():
layer = property_layers.get(layer_name, None)
if not isinstance(layer, PropertyLayer):
if not isinstance(
layer,
PropertyLayer | mesa.experimental.cell_space.property_layer.PropertyLayer,
):
continue

data = layer.data.astype(float) if layer.data.dtype == bool else layer.data
Expand Down Expand Up @@ -212,7 +215,7 @@ def draw_property_layers(
layer_name, [(0, 0, 0, 0), (*rgba_color[:3], alpha)]
)
im = ax.imshow(
rgba_data.transpose(1, 0, 2),
rgba_data,
origin="lower",
)
if colorbar:
Expand All @@ -226,7 +229,7 @@ def draw_property_layers(
if isinstance(cmap, list):
cmap = LinearSegmentedColormap.from_list(layer_name, cmap)
im = ax.imshow(
data.T,
data,
cmap=cmap,
alpha=alpha,
vmin=vmin,
Expand Down

0 comments on commit f72a268

Please sign in to comment.