Skip to content

Commit 0868f4b

Browse files
authored
Jupyter_viz: Allow measures to be None (#2163)
Currently measures crashed when it's None (which is the default). The only way to circumvent this is adding [], but that's non-ideal and not obvious. This PR fixes that, so that measures can actually be the default value of None. This also proves we need to test Jupyter viz in notebooks, not only in console, since both have different code paths.
1 parent 4cc0c82 commit 0868f4b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

mesa/visualization/jupyter_viz.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,15 @@ def render_in_jupyter():
143143
# otherwise, do nothing (do not draw space)
144144

145145
# 5. Plots
146-
for measure in measures:
147-
if callable(measure):
148-
# Is a custom object
149-
measure(model)
150-
else:
151-
components_matplotlib.PlotMatplotlib(
152-
model, measure, dependencies=dependencies
153-
)
146+
if measures:
147+
for measure in measures:
148+
if callable(measure):
149+
# Is a custom object
150+
measure(model)
151+
else:
152+
components_matplotlib.PlotMatplotlib(
153+
model, measure, dependencies=dependencies
154+
)
154155

155156
def render_in_browser():
156157
# if space drawer is disabled, do not include it

0 commit comments

Comments
 (0)