Skip to content

Commit

Permalink
Do some TODOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuzka committed Nov 30, 2023
1 parent 52f16ff commit 82d7bf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/popy/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def join(self, agent: _agent.Agent) -> bool: # noqa: ARG002
"""
# TODO: This method name makes little sense. "join" implies that the agent is added to the
# location once the check passes?
# -> What is a better name?
return True

# TODO: Rename to split()
Expand Down
19 changes: 10 additions & 9 deletions src/popy/pop_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(
model: Optional[popy.Model] = None,
seed: int = 999,
) -> None:
"""Instantiate a population make for a specific model.
"""Instantiate a population maker for a specific model.
Args:
model (popy.Model): Model, for which a population should be created
Expand Down Expand Up @@ -90,7 +90,6 @@ def draw_sample(
sample = df.loc[df[sample_level] == random_id, :].copy()

# create new unique ids for sample level variable
# TODO: Hinweis/Warnung printen, dass die originale sample_level-Spalte ersetzt wurde
if replace_sample_level_column:
sample.loc[:, sample_level + "_original"] = sample.loc[:, sample_level]
sample.loc[:, sample_level] = sample_cluster_id
Expand Down Expand Up @@ -121,13 +120,14 @@ def create_agents(self, df: pd.DataFrame, agent_class) -> popy.AgentList:
df = df.copy()

# create one agent for each row in df

# TODO: sicherstellen, dass kein Attribut mit dem Namen `id` erstellt wird
agents = []
for _, row in df.iterrows():
agent = agent_class(model=self.model)
for col_name in df.columns:
setattr(agent, col_name, row[col_name])
if col_name == "id":
raise Exception("You are not allowed to set an agent attribute called `id`.")
else:
setattr(agent, col_name, row[col_name])
agents.append(agent)

agents = popy.AgentList(model=self.model, objs=agents)
Expand Down Expand Up @@ -238,12 +238,13 @@ def make_it_a_list_if_it_is_no_list(x):
break

# if agents are not assigned and all locations are full
# TODO: hier verschiedene Möglichkeiten anbieten, was passieren soll, wenn Agenten übrigen bleiben
if not assigned:
random_group_list = self.rng.choice(group_lists)
# assign agents
# sort by the number of assigned agents
group_lists.sort(key=lambda x: x.len())

# assign agents to the group_list with the fewest members
for agent in sticky_agents:
random_group_list.append(agent)
group_lists[0].append(agent)
assigned = True

#####################################################################################################
Expand Down

0 comments on commit 82d7bf5

Please sign in to comment.