From aad21831b08c157b1c25b6f431b83b004cdb9935 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Sat, 23 Dec 2023 16:09:16 +0100 Subject: [PATCH] If a single agent, convert to list --- src/mesa_interactive/components/grid.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa_interactive/components/grid.py b/src/mesa_interactive/components/grid.py index fef519f..ab4f02f 100644 --- a/src/mesa_interactive/components/grid.py +++ b/src/mesa_interactive/components/grid.py @@ -9,6 +9,8 @@ def get_agent_data_from_coord_iter(agents_per_coordinate): for agents, (x, y) in agents_per_coordinate: if agents: # Checking if the list is non-empty + if agents not isinstance(list): + agents = [agents] for agent in agents: agent_data = json.loads( json.dumps(agent.__dict__, skipkeys=True, default=str)