pykappa.mixture¶
Functions
|
Group components by isomorphism. |
|
Get all agents within a distance radius of the given agents. |
Classes
|
Represents bonds between sites. |
|
A collection of agents and their connections. |
|
Specifies changes to be applied to a mixture. |
- class pykappa.mixture.Edge(site1, site2)[source]¶
Represents bonds between sites. Edge(x, y) equals Edge(y, x).
- class pykappa.mixture.Mixture(patterns=None, track_components=False)[source]¶
A collection of agents and their connections.
Optionally tracks connected components, enabled via enable_component_tracking().
- Parameters:
patterns (Iterable[Pattern] | None)
track_components (bool)
- agents¶
Indexed set of all agents in the mixture.
- _components¶
Indexed set of components if enabled, else None.
- Type:
- _embeddings¶
Cache of embeddings for tracked components.
- _max_embedding_width¶
Maximum diameter of tracked components.
- Type:
int
- add(component)[source]¶
Add a component to the mixture.
- Parameters:
component (Component)
- Return type:
None
- agents: IndexedSet[Agent]¶
- apply_update(update)[source]¶
Apply a collection of changes to the mixture.
- Parameters:
update (MixtureUpdate)
- Return type:
None
- property component_tracking: bool¶
Whether connected components are being tracked.
- property components: IndexedSet[Component]¶
- embeddings(component)[source]¶
Get embeddings of a tracked component (not accounting for symmetries).
- Raises:
KeyError – If component is not being tracked.
- Parameters:
component (Component)
- Return type:
- embeddings_in_component(match_pattern, mixture_component)[source]¶
Get embeddings of a pattern within a specific component.
- Parameters:
- Return type:
- enable_component_tracking()[source]¶
Turn on connected-component tracking for this mixture.
- Return type:
None
- classmethod from_kappa(patterns)[source]¶
Create a mixture from Kappa pattern strings and counts.
- Parameters:
patterns (dict[str, int]) – Dictionary mapping pattern strings to copy counts.
- Return type:
Self
- instantiate(pattern, n_copies=1)[source]¶
Add instances of a pattern to the mixture.
- Parameters:
pattern (Pattern | str) – Pattern to instantiate, or Kappa string.
n_copies (int) – Number of copies to create.
- Raises:
AssertionError – If pattern is underspecified.
- Return type:
None
- property kappa_str: str¶
The mixture in Kappa format with %init declarations.
- class pykappa.mixture.MixtureUpdate(agents_to_add=<factory>, agents_to_remove=<factory>, edges_to_add=<factory>, edges_to_remove=<factory>, agents_changed=<factory>)[source]¶
Specifies changes to be applied to a mixture.
- Parameters:
- connect_sites(site1, site2)[source]¶
Specify to create an edge between two sites. If the sites are bound to other sites, indicates to remove those edges.
- disconnect_site(site)[source]¶
Specify that a site should be unbound.
- Parameters:
site (Site)
- Return type:
None
- register_changed_agent(agent)[source]¶
Register an agent as having internal state changes.
- Parameters:
agent (Agent)
- Return type:
None