From bf1ccd9328f260a746c21a6bad7e15a7a6898dc3 Mon Sep 17 00:00:00 2001 From: Adam Amer <136176500+adamamer20@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:37:38 +0200 Subject: [PATCH] Changes to AgentSetDF and AgentsDF before time.py -> CopyMixin (#16) * Modified AgentSet and AgentsDF before adding mesa_frames/time.py. Created a CopyMixin for copy and deepcopy methods to let both AgentSet and Scheduler inherit. Added possibility of using 'do' method with a mask in AgentSetDF, such that the Scheduler can use it to run the method only on a subset of agents. Minor fixes to type hints and docstrings. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pre-commit fixes * minor fixes for tests * moved sampling to last step (otherwise, can sample outside of final mask) * from typing to typing-extensions * added mask to AgentsDF.do * bug fixes, added tests for AgentsDF * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * change to polars._typing and added test.__init__ * changed df comparison * keys fix * fix * change to .toml for polars._typing * added comment for typing-extensions, removed geopandas(will be added in the future for mesa-frames.geo) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/api/mesa_frames.html | 8 +- docs/api/mesa_frames/agent.html | 6 +- docs/api/mesa_frames/model.html | 18 +- docs/scripts/readme_plot.py | 5 +- mesa_frames/__init__.py | 7 + mesa_frames/abstract/agents.py | 297 ++++--- mesa_frames/abstract/mixin.py | 144 ++++ mesa_frames/concrete/agents.py | 387 +++++++--- mesa_frames/concrete/agentset_pandas.py | 170 +++-- mesa_frames/concrete/agentset_polars.py | 194 +++-- mesa_frames/concrete/model.py | 12 +- mesa_frames/datacollection.py | 1 + mesa_frames/types.py | 14 +- pyproject.toml | 4 +- tests/__init__.py | 0 tests/test_agents.py | 976 ++++++++++++++++++++++++ tests/test_agentset_pandas.py | 105 +-- tests/test_agentset_polars.py | 101 ++- 18 files changed, 1959 insertions(+), 490 deletions(-) create mode 100644 mesa_frames/abstract/mixin.py create mode 100644 tests/__init__.py create mode 100644 tests/test_agents.py diff --git a/docs/api/mesa_frames.html b/docs/api/mesa_frames.html index ed2b1d9..52f4048 100644 --- a/docs/api/mesa_frames.html +++ b/docs/api/mesa_frames.html @@ -42,10 +42,10 @@