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 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Loading