Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and quaquel committed Sep 5, 2024
1 parent 2f1cd4d commit d168eb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def __contains__(self, agent: Agent) -> bool:
return agent in self._agents

def select(
self,
filter_func: Callable[[Agent], bool] | None = None,
at_most: int | float = float("inf"),
inplace: bool = False,
agent_type: type[Agent] | None = None,
n: int | None = None,
self,
filter_func: Callable[[Agent], bool] | None = None,
at_most: int | float = float("inf"),
inplace: bool = False,
agent_type: type[Agent] | None = None,
n: int | None = None,
) -> AgentSet:
"""
Select a subset of agents from the AgentSet based on a filter function and/or quantity limit.
Expand Down Expand Up @@ -190,7 +190,7 @@ def agent_generator(filter_func, agent_type, at_most):
if count >= at_most:
break
if (not filter_func or filter_func(agent)) and (
not agent_type or isinstance(agent, agent_type)
not agent_type or isinstance(agent, agent_type)
):
yield agent
count += 1
Expand Down Expand Up @@ -225,10 +225,10 @@ def shuffle(self, inplace: bool = False) -> AgentSet:
)

def sort(
self,
key: Callable[[Agent], Any] | str,
ascending: bool = False,
inplace: bool = False,
self,
key: Callable[[Agent], Any] | str,
ascending: bool = False,
inplace: bool = False,
) -> AgentSet:
"""
Sort the agents in the AgentSet based on a specified attribute or custom function.
Expand Down
1 change: 1 addition & 0 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def test_agentset_get():
results = agentset.get("unknown_attribute", True)
assert all(results) is True


def test_agentset_agg():
model = Model()
agents = [TestAgent(model) for i in range(10)]
Expand Down

0 comments on commit d168eb6

Please sign in to comment.