Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return types of some NetworkGrid methods #1505

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,6 @@ def get_neighbors(self, node_id: int, include_center: bool = False) -> list[int]
neighbors = list(self.G.neighbors(node_id))
if include_center:
neighbors.append(node_id)

return neighbors

def move_agent(self, agent: Agent, node_id: int) -> None:
Expand All @@ -990,7 +989,7 @@ def is_cell_empty(self, node_id: int) -> bool:
"""Returns a bool of the contents of a cell."""
return self.G.nodes[node_id]["agent"] == self.default_val()

def get_cell_list_contents(self, cell_list: list[int]) -> list[GridContent]:
def get_cell_list_contents(self, cell_list: list[int]) -> list[Agent]:
"""Returns a list of the agents contained in the nodes identified
in `cell_list`; nodes with empty content are excluded.
"""
Expand All @@ -1001,11 +1000,11 @@ def get_cell_list_contents(self, cell_list: list[int]) -> list[GridContent]:
]
return [item for sublist in list_of_lists for item in sublist]

def get_all_cell_contents(self) -> list[GridContent]:
def get_all_cell_contents(self) -> list[Agent]:
"""Returns a list of all the agents in the network."""
return self.get_cell_list_contents(self.G)

def iter_cell_list_contents(self, cell_list: list[int]) -> Iterator[GridContent]:
def iter_cell_list_contents(self, cell_list: list[int]) -> Iterator[Agent]:
"""Returns an iterator of the agents contained in the nodes identified
in `cell_list`; nodes with empty content are excluded.
"""
Expand Down