finesse.utilities.network_filter module
- class finesse.utilities.network_filter.ComponentNetworkFilter(model: Model, root: str | ModelElement | Node | None = None, radius: int | None = None, undirected: bool = True, add_edge_info: bool = False, add_detectors: bool = False)[source]
Bases:
NetworkFilterBase- network_type = 'component'
- class finesse.utilities.network_filter.FullNetworkFilter(model: Model, root: str | ModelElement | Node | None = None, radius: int | None = None, undirected: bool = True, add_edge_info: bool = False, add_detectors: bool = False)[source]
Bases:
NodeNetworkFilter- network_type = 'full'
- class finesse.utilities.network_filter.NetworkFilterBase(model: Model, root: str | ModelElement | Node | None = None, radius: int | None = None, undirected: bool = True, add_edge_info: bool = False, add_detectors: bool = False)[source]
Bases:
ABCAbstract base class that implements distance based filtering of a model graph. Should mostly be used to directly call the
runmethod after initialization, not guaranteed that the state makes sense if it is kept alive.Used by
finesse.model.Model.plot_graph()andfinesse.model.Model.component_tree(), see also their docstrings for more clarification on the arguments.- network_type: ClassVar[NetworkType]
- root: str | ModelElement | Node | None = None
- property root_str: str[source]
Transforms the
rootargument into a string that represents a node in the relevant graph. Must implement _root_to_str and _root_options in the subclass to makes this work.Returns
- str
Root node as the string name in the graph
- class finesse.utilities.network_filter.NetworkType(*values)[source]
Bases:
Enum- COMPONENT = 'component'
- FULL = 'full'
- OPTICAL = 'optical'
- PORT = 'port'
- property filter_class: type[NetworkFilterBase][source]
Get the relevant filter class for this network type.
Returns
- type[NetworkFilterBase]
The relevant filter class
- get_network(model: Model, add_edge_info: bool = False) nx.Graph[source]
Retrieve the relevant network for this network type.
Parameters
- modelModel
Model to retrieve the netwrok from
- add_edge_infobool, optional
Add metadata to the component network on via which ports components are connected, by default False. Ignore for any type other than
NetworkType.COMPONENT
Returns
- nx.Graph
The relevant model graph
Raises
- NotImplementedError
If there is no implementation for newly added network types.
- class finesse.utilities.network_filter.NodeNetworkFilter(model: Model, root: str | ModelElement | Node | None = None, radius: int | None = None, undirected: bool = True, add_edge_info: bool = False, add_detectors: bool = False)[source]
Bases:
NetworkFilterBase