-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Split agent.py into agent.py and agentset.py #3315
Description
Something very long on my to-do list: I put the original AgentSet in agent.py, and now that file has grown over a thousand lines. I almost instantly regretted doing that, but now finally took the time to fix it.
I split mesa/agent.py into two modules: mesa/agent.py now contains only the Agent class, and I moved the collection machinery (AbstractAgentSet, AgentSet, _HardKeyAgentSet, and GroupBy) into a new mesa/agentset.py. Tests were split the same way.
In a high-exception, I did the work directly on main. This because I really wanted to preserve full git history (including blame etc.) for both of the new files. This “split-with-history” approach relies on doing the change as a rename/trim sequence and then keeping the resulting merge commit (i.e., not squashing/rebasing) so Git can track both lineages back to the original file. Given our PR workflow often defaults to squash/rebase (and fast-forward doesn’t create the necessary merge commit), landing the preparatory commits on main avoids us accidentally losing that history during review/merge and keeps git log --follow/git blame useful across the split.
Implemented in dc86ccf, 44820da, f857b37, b5e94a7 (merge) and 50e1b01 (cleanup).
New file with full git history