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

Changes to AgentSetDF and AgentsDF before time.py -> CopyMixin #16

Merged
merged 20 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
80e10c7
Modified AgentSet and AgentsDF before adding
adamamer20 Jul 1, 2024
eef3b66
Merge branch 'main' into masked_do_agentset
adamamer20 Jul 1, 2024
a3aca41
Merge branch 'main' of https://github.com/adamamer20/mesa-frames into…
adamamer20 Jul 2, 2024
3ec06a9
Merge branch 'main' of https://github.com/adamamer20/mesa-frames into…
adamamer20 Jul 2, 2024
d3cc2aa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 2, 2024
7ee18ef
pre-commit fixes
adamamer20 Jul 2, 2024
d11fb3a
minor fixes for tests
adamamer20 Jul 2, 2024
4a8ab48
Merge branch 'main' into masked_do_agentset
adamamer20 Jul 2, 2024
ba7d17b
moved sampling to last step (otherwise, can sample outside of final m…
adamamer20 Jul 2, 2024
f69d7b2
from typing to typing-extensions
adamamer20 Jul 3, 2024
70821db
added mask to AgentsDF.do
adamamer20 Jul 3, 2024
d5201f8
bug fixes, added tests for AgentsDF
adamamer20 Jul 4, 2024
a6b7c99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 4, 2024
c9aaa22
change to polars._typing and added test.__init__
adamamer20 Jul 4, 2024
9264523
Merge branch 'masked_do_agentset' of https://github.com/adamamer20/me…
adamamer20 Jul 4, 2024
d8ea0c4
changed df comparison
adamamer20 Jul 4, 2024
ca0b362
keys fix
adamamer20 Jul 4, 2024
c744405
fix
adamamer20 Jul 4, 2024
ce5718f
change to .toml for polars._typing
adamamer20 Jul 5, 2024
db0bdf8
added comment for typing-extensions, removed geopandas(will be added …
adamamer20 Jul 5, 2024
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
8 changes: 4 additions & 4 deletions docs/api/mesa_frames.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ <h2>Submodules</h2>
<h1 class="modulename">
mesa_frames </h1>





</section>
</main>
<script>
Expand Down
6 changes: 3 additions & 3 deletions docs/api/mesa_frames/agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h2>API Documentation</h2>
<h1 class="modulename">
mesa_frames<wbr>.agent </h1>


<input id="mod-agent-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">

<label class="view-source-button" for="mod-agent-view-source"><span>View Source</span></label>
Expand Down Expand Up @@ -161,7 +161,7 @@ <h1 class="modulename">
<section id="AgentDF">
<input id="AgentDF-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr class">

<span class="def">class</span>
<span class="name">AgentDF</span>:

Expand Down Expand Up @@ -309,7 +309,7 @@ <h6 id="attributes">Attributes</h6>
<section id="GeoAgentDF">
<input id="GeoAgentDF-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr class">

<span class="def">class</span>
<span class="name">GeoAgentDF</span><wbr>(<span class="base"><a href="#AgentDF">AgentDF</a></span>):

Expand Down
18 changes: 9 additions & 9 deletions docs/api/mesa_frames/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h2>API Documentation</h2>
<h1 class="modulename">
mesa_frames<wbr>.model </h1>


<input id="mod-model-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">

<label class="view-source-button" for="mod-model-view-source"><span>View Source</span></label>
Expand Down Expand Up @@ -402,7 +402,7 @@ <h1 class="modulename">
<section id="ModelDF">
<input id="ModelDF-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr class">

<span class="def">class</span>
<span class="name">ModelDF</span>:

Expand Down Expand Up @@ -741,7 +741,7 @@ <h6 id="attributes">Attributes</h6>
<div id="ModelDF.__init__" class="classattr">
<input id="ModelDF.__init__-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="name">ModelDF</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">unique_id</span><span class="p">:</span> <span class="nb">int</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span>, </span><span class="param"><span class="n">space</span><span class="o">=</span><span class="kc">None</span></span>)</span>

<label class="view-source-button" for="ModelDF.__init__-view-source"><span>View Source</span></label>
Expand Down Expand Up @@ -801,7 +801,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.get_agents_of_type" class="classattr">
<input id="ModelDF.get_agents_of_type-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">get_agents_of_type</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">agent_type</span><span class="p">:</span> <span class="nb">type</span><span class="p">[</span><span class="n"><a href="agent.html#AgentDF">mesa_frames.agent.AgentDF</a></span><span class="p">]</span></span><span class="return-annotation">) -> <span class="n">pandas</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">series</span><span class="o">.</span><span class="n">Series</span>:</span></span>

Expand Down Expand Up @@ -840,7 +840,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.run_model" class="classattr">
<input id="ModelDF.run_model-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">run_model</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">n_steps</span><span class="p">:</span> <span class="nb">int</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span>, </span><span class="param"><span class="n">merged_mro</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span></span><span class="return-annotation">) -> <span class="kc">None</span>:</span></span>

Expand Down Expand Up @@ -898,7 +898,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.step" class="classattr">
<input id="ModelDF.step-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">step</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">merged_mro</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span></span><span class="return-annotation">) -> <span class="kc">None</span>:</span></span>

Expand Down Expand Up @@ -948,7 +948,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.reset_randomizer" class="classattr">
<input id="ModelDF.reset_randomizer-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">reset_randomizer</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">seed</span><span class="p">:</span> <span class="nb">int</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="kc">None</span>:</span></span>

Expand Down Expand Up @@ -986,7 +986,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.create_agents" class="classattr">
<input id="ModelDF.create_agents-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">create_agents</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">n_agents</span><span class="p">:</span> <span class="nb">int</span>,</span><span class="param"> <span class="n">p_agents</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">type</span><span class="p">[</span><span class="n"><a href="agent.html#AgentDF">mesa_frames.agent.AgentDF</a></span><span class="p">],</span> <span class="nb">float</span><span class="p">]</span></span><span class="return-annotation">) -> <span class="kc">None</span>:</span></span>

Expand Down Expand Up @@ -1133,7 +1133,7 @@ <h6 id="parameters">Parameters</h6>
<div id="ModelDF.update_agents_masks" class="classattr">
<input id="ModelDF.update_agents_masks-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="def">def</span>
<span class="name">update_agents_masks</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span></span><span class="return-annotation">) -> <span class="kc">None</span>:</span></span>

Expand Down
5 changes: 2 additions & 3 deletions docs/scripts/readme_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MoneyAgentPolars(AgentSetPolars):
def __init__(self, n: int, model: ModelDF):
super().__init__(model)
## Adding the agents to the agent set
# 1. Changing the agents attribute directly (not reccomended, if other agents were added before, they will be lost)
# 1. Changing the agents attribute directly (not recommended, if other agents were added before, they will be lost)
"""self.agents = pl.DataFrame(
{"unique_id": pl.arange(n, eager=True), "wealth": pl.ones(n, eager=True)}
)"""
Expand Down Expand Up @@ -150,7 +150,7 @@ class MoneyAgentPandas(AgentSetPandas):
def __init__(self, n: int, model: ModelDF) -> None:
super().__init__(model)
## Adding the agents to the agent set
# 1. Changing the agents attribute directly (not reccomended, if other agents were added before, they will be lost)
# 1. Changing the agents attribute directly (not recommended, if other agents were added before, they will be lost)
# self.agents = pd.DataFrame({"unique_id": np.arange(n), "wealth": np.ones(n)})
# 2. Adding the dataframe with add
# self.add(pd.DataFrame({"unique_id": np.arange(n), "wealth": np.ones(n)}))
Expand Down Expand Up @@ -226,7 +226,6 @@ def mesa_frames_pandas(n_agents: int) -> None:


def main():

sns.set_theme(style="whitegrid")

out = perfplot.bench(
Expand Down
7 changes: 7 additions & 0 deletions mesa_frames/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
from mesa_frames.concrete.agentset_pandas import AgentSetPandas
from mesa_frames.concrete.agentset_polars import AgentSetPolars
from mesa_frames.concrete.model import ModelDF

__all__ = [
"AgentsDF",
"AgentSetPandas",
"AgentSetPolars",
"ModelDF",
]
Loading