Skip to content

Commit dbda4e5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 95a6b65 commit dbda4e5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

mesa/visualization/mpl_space_drawing.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ def draw_orthogonal_grid(
271271

272272
# First draw cell colors if they exist
273273
if hasattr(space, "all_cells"): # Check if it's a cell space
274-
cell_colors = np.full((space.height, space.width, 4), [1, 1, 1, 0]) # Transparent default
275-
274+
cell_colors = np.full(
275+
(space.height, space.width, 4), [1, 1, 1, 0]
276+
) # Transparent default
277+
276278
for cell in space.all_cells:
277279
if hasattr(cell, "color"):
278280
x, y = cell.coordinate
@@ -285,9 +287,9 @@ def draw_orthogonal_grid(
285287
UserWarning,
286288
stacklevel=2,
287289
)
288-
290+
289291
# Plot the cell colors
290-
ax.imshow(cell_colors, origin='lower', interpolation='nearest')
292+
ax.imshow(cell_colors, origin="lower", interpolation="nearest")
291293

292294
# gather agent data
293295
s_default = (180 / max(space.width, space.height)) ** 2
@@ -309,6 +311,7 @@ def draw_orthogonal_grid(
309311

310312
return ax
311313

314+
312315
def draw_hex_grid(
313316
space: HexGrid,
314317
agent_portrayal: Callable,
@@ -338,20 +341,20 @@ def draw_hex_grid(
338341
if hasattr(space, "all_cells"):
339342
patches = []
340343
offset = math.sqrt(0.75)
341-
344+
342345
for cell in space.all_cells:
343346
x, y = cell.coordinate
344347
if y % 2 == 0:
345348
x += 0.5
346349
y *= offset
347-
350+
348351
hex_patch = RegularPolygon(
349352
(x, y),
350353
numVertices=6,
351354
radius=math.sqrt(1 / 3),
352355
orientation=np.radians(120),
353356
)
354-
357+
355358
if hasattr(cell, "color"):
356359
try:
357360
hex_patch.set_facecolor(cell.color)
@@ -361,12 +364,12 @@ def draw_hex_grid(
361364
UserWarning,
362365
stacklevel=2,
363366
)
364-
hex_patch.set_facecolor('none')
367+
hex_patch.set_facecolor("none")
365368
else:
366-
hex_patch.set_facecolor('none')
367-
369+
hex_patch.set_facecolor("none")
370+
368371
patches.append(hex_patch)
369-
372+
370373
# Add colored hexagons
371374
cell_collection = PatchCollection(patches, match_original=True)
372375
ax.add_collection(cell_collection)

0 commit comments

Comments
 (0)