Skip to content

Commit

Permalink
Deprecate neighbor_iter in favor of iter_neighbors
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed Mar 8, 2022
1 parent 68b6631 commit b698ec8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ def neighbor_iter(
moore: Boolean for whether to use Moore neighborhood (including
diagonals) or Von Neumann (only up/down/left/right).
"""
neighborhood = self.get_neighborhood(pos, moore=moore)
return self.iter_cell_list_contents(neighborhood)
from warnings import warn
warn(
"`neighbor_iter` is deprecated in favor of `iter_neighbors` "
"and will be removed in the subsequent version."
)
return self.iter_neighbors(pos, moore)

def iter_neighborhood(
self,
Expand Down Expand Up @@ -606,7 +610,7 @@ class HexGrid(Grid):
Methods:
get_neighbors: Returns the objects surrounding a given cell.
get_neighborhood: Returns the cells surrounding a given cell.
neighbor_iter: Iterates over position neighbors.
iter_neighbors: Iterates over position neighbors.
iter_neighborhood: Returns an iterator over cell coordinates that are
in the neighborhood of a certain point.
"""
Expand Down Expand Up @@ -679,8 +683,12 @@ def neighbor_iter(self, pos: Coordinate) -> Iterator[GridContent]:
Args:
pos: (x,y) coords tuple for the position to get the neighbors of.
"""
neighborhood = self.iter_neighborhood(pos)
return self.iter_cell_list_contents(neighborhood)
from warnings import warn
warn(
"`neighbor_iter` is deprecated in favor of `iter_neighbors` "
"and will be removed in the subsequent version."
)
return self.iter_neighbors(pos)

def get_neighborhood(
self, pos: Coordinate, include_center: bool = False, radius: int = 1
Expand Down

0 comments on commit b698ec8

Please sign in to comment.