From aad21831b08c157b1c25b6f431b83b004cdb9935 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Sat, 23 Dec 2023 16:09:16 +0100 Subject: [PATCH 1/2] 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) From 7eb6eb848b66a032b3296d61c50250539d520a46 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Sat, 23 Dec 2023 16:17:17 +0100 Subject: [PATCH 2/2] fix --- src/mesa_interactive/components/grid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa_interactive/components/grid.py b/src/mesa_interactive/components/grid.py index ab4f02f..ed93d72 100644 --- a/src/mesa_interactive/components/grid.py +++ b/src/mesa_interactive/components/grid.py @@ -9,7 +9,7 @@ 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): + if not isinstance(agents, list): agents = [agents] for agent in agents: agent_data = json.loads(