Skip to content

Commit

Permalink
rename (sub-)group() to (sub-)split()
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuzka committed Dec 11, 2023
1 parent 69c375e commit 4bc460c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/popy/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def join(self, agent: _agent.Agent) -> bool: # noqa: ARG002
return True

# TODO: Rename to split()
def group(self, agent: _agent.Agent) -> float | str | list | None: # noqa: ARG002
def split(self, agent: _agent.Agent) -> float | str | list | None: # noqa: ARG002
"""~ User interface ~ Allow to create subtypes of this type of location.
Allows to create subtypes of this type of location if the location instances are created by
Expand All @@ -136,7 +136,7 @@ def group(self, agent: _agent.Agent) -> float | str | list | None: # noqa: ARG0
return None

# TODO: Rename to subsplit()
def subgroup(self, agent: _agent.Agent) -> Any:
def subsplit(self, agent: _agent.Agent) -> Any:
return None

def is_affiliated(self, agent: _agent.Agent) -> bool:
Expand Down Expand Up @@ -232,21 +232,21 @@ def melt(self):


class LineLocation(Location):
def subgroup(self, agent):
def subsplit(self, agent):
pos = self.group_agents.index(agent)
right = (pos + 1)
return [pos, right]


class RingLocation(Location):
def subgroup(self, agent):
def subsplit(self, agent):
pos = self.group_agents.index(agent)
right = (pos + 1) % len(self.group_agents)
return [pos, right]


class GridLocation(Location):
def subgroup(self, agent):
def subsplit(self, agent):
row_len = math.ceil(math.sqrt(self.size))
right_edge_positions = [row_len * i - 1 for i in range(row_len)]

Expand All @@ -268,7 +268,7 @@ def subgroup(self, agent):


class TreeLocation(Location):
def subgroup(self, agent):
def subsplit(self, agent):
if isinstance(self, StarLocation):
self.n_branches = self.size - 1

Expand Down
6 changes: 3 additions & 3 deletions src/popy/pop_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _get_mother_group_id(self, agent: _agent, location_dummy: _location) -> str:
def _get_split_values(self, agents: [_agent], location_dummy: _location, allow_nesting: bool = False) -> {int | str}:
all_values = []
for agent in agents:
agent_values = make_it_a_list_if_it_is_no_list(location_dummy.group(agent))
agent_values = make_it_a_list_if_it_is_no_list(location_dummy.split(agent))

if allow_nesting:
# Add mother location's value to the value of the lower level location
Expand Down Expand Up @@ -420,7 +420,7 @@ def create_locations(
agent_subgroup_value
for agent in group_list
for agent_subgroup_value
in make_it_a_list_if_it_is_no_list(location_dummy.subgroup(agent))
in make_it_a_list_if_it_is_no_list(location_dummy.subsplit(agent))
}

# for each group of agents assigned to a specific sublocation
Expand All @@ -431,7 +431,7 @@ def create_locations(

#for agent in group_affiliated_agents:
for agent in group_list:
agent_subgroup_value = make_it_a_list_if_it_is_no_list(location_dummy.subgroup(agent))
agent_subgroup_value = make_it_a_list_if_it_is_no_list(location_dummy.subsplit(agent))
if subgroup_value in agent_subgroup_value:
subgroup_affiliated_agents.append(agent)

Expand Down

0 comments on commit 4bc460c

Please sign in to comment.