From 49db41ca01026b18afc9a04fe7f7fe0a2cee5953 Mon Sep 17 00:00:00 2001 From: Corvince <13568919+Corvince@users.noreply.github.com> Date: Sun, 26 Apr 2020 21:58:15 +0200 Subject: [PATCH] use filter for emptiness check --- mesa/space.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mesa/space.py b/mesa/space.py index 38a51db42d7..804ef910c5f 100644 --- a/mesa/space.py +++ b/mesa/space.py @@ -310,10 +310,7 @@ def iter_cell_list_contents( An iterator of the contents of the cells identified in cell_list """ - for (x, y) in cell_list: - content = self.grid[x][y] - if not content == self.default_val(): - yield content + return filter(None, (self.grid[x][y] for x, y in cell_list)) @accept_tuple_argument def get_cell_list_contents(