From 823fd091767097cbd41c2f1be0516d3576d82b0b Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Sat, 21 Sep 2024 09:42:31 +0200 Subject: [PATCH] Add docstring for shuffle_do --- mesa/agent.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mesa/agent.py b/mesa/agent.py index 455cde19c9d..ec98efaad08 100644 --- a/mesa/agent.py +++ b/mesa/agent.py @@ -294,6 +294,10 @@ def do(self, method: str | Callable, *args, **kwargs) -> AgentSet: return self def shuffle_do(self, method: str | Callable, *args, **kwargs) -> AgentSet: + """Shuffle the agents in the AgentSet and then invoke a method or function on each agent. + + It's a fast, optimized version of calling shuffle() followed by do(). + """ agents = list(self._agents.keys()) self.random.shuffle(agents)