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

Mk/mutate #129

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/pop2net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from .exceptions import Pop2netException
from .inspector import NetworkInspector
from .location import Location
from .location import MagicLocation
from .location import MeltLocation
from .location_designer import LocationDesigner
from .location_designer import MeltLocationDesigner
from .model import Model
from .sequences import LocationList

Expand All @@ -17,8 +17,8 @@
"Agent",
"Pop2netException",
"Location",
"MagicLocation",
"MeltLocation",
"LocationDesigner",
"MeltLocationDesigner",
"NetworkInspector",
"Model",
"LocationList",
Expand Down
24 changes: 12 additions & 12 deletions src/pop2net/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ def setup(self) -> None:
This is executed on the instantiation of each agent.
"""

def neighbors(self, location_classes: list | None = None) -> ap.AgentList:
def neighbors(self, location_labels: list[str] | None = None) -> ap.AgentList:
"""Return all neighbors of an agent.

Convenience method that returns all neighbors over all locations this agent is currently
located in. The locations to be considered can be defined with location_classes.
located in. The locations to be considered can be defined with location_labels.

Args:
location_classes: A list of location_classes.
location_labels: A list of location_labels.

Returns:
All agents co-located with this agent over all locations.
"""
return self.model.neighbors_of_agent(self, location_classes=location_classes)
return self.model.neighbors_of_agent(self, location_labels=location_labels)

def shared_locations(self, agent, location_classes: list | None = None):
def shared_locations(self, agent, location_labels: list[str] | None = None):
return self.model.locations_between_agents(
agent1=self,
agent2=agent,
location_classes=location_classes,
location_labels=location_labels,
)

def add_location(self, location: _location.Location, weight: float | None = None) -> None:
Expand Down Expand Up @@ -112,21 +112,21 @@ def locations(self) -> _sequences.LocationList:
"""
return self.model.locations_of_agent(self)

def get_agent_weight(self, agent: Agent, location_classes: list | None = None) -> float:
def get_agent_weight(self, agent: Agent, location_labels: list | None = None) -> float:
"""Return the edge weight between this agent and a given other agent.

This is summed over all shared locations.

Args:
agent: The other agent.
location_classes (list): A list of location classes to specify the type of locations
location_labels (list): A list of location classes to specify the type of locations
which are considered.

Returns:
A weight of the contact between the two agents.
"""
weight = 0
for location in self.shared_locations(agent=agent, location_classes=location_classes):
for location in self.shared_locations(agent=agent, location_labels=location_labels):
weight += location.project_weights(agent1=self, agent2=agent)
return weight

Expand Down Expand Up @@ -155,7 +155,7 @@ def connect(self, agent: Agent, location_cls: type, weight: float | None = None)
def disconnect(
self,
neighbor: Agent,
location_classes: list | None = None,
location_labels: list | None = None,
remove_self=True,
remove_neighbor=True,
remove_locations: bool = False,
Expand All @@ -169,7 +169,7 @@ def disconnect(

Args:
neighbor (Agent): An agent to disconnect from.
location_classes (list | None, optional): A list of location types to specify which
location_labels (list | None, optional): A list of location types to specify which
shared locations are considered. Defaults to None.
remove_self (bool): Should the agent be removed from the shared locations?
Defaults to True.
Expand All @@ -180,7 +180,7 @@ def disconnect(
"""
shared_locations = self.shared_locations(
agent=neighbor,
location_classes=location_classes,
location_labels=location_labels,
)

for location in shared_locations:
Expand Down
Loading