Skip to content

Commit

Permalink
space: Document the logic in iter_cell_list_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
rht authored and tpike3 committed Mar 27, 2022
1 parent 77e8dfa commit a99fa4d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ def iter_cell_list_contents(
Returns:
An iterator of the contents of the cells identified in cell_list
"""
# Note: filter(None, iterator) filters away an element of iterator that
# is falsy. Hence, iter_cell_list_contents returns only non-empty
# contents.
return filter(None, (self.grid[x][y] for x, y in cell_list))

@accept_tuple_argument
Expand Down

0 comments on commit a99fa4d

Please sign in to comment.