Skip to content

Commit

Permalink
improve iter_cell_list_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Corvince committed Feb 5, 2021
1 parent 2a917aa commit cccd438
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def iter_cell_list_contents(
An iterator of the contents of the cells identified in cell_list
"""
return (self[x][y] for x, y in cell_list if not self.is_cell_empty((x, y)))
for (x, y) in cell_list:
content = self.grid[x][y]
if not content == self.default_val():
yield content

@accept_tuple_argument
def get_cell_list_contents(
Expand Down

0 comments on commit cccd438

Please sign in to comment.