2020 DotGraphAttributeSet ,
2121 DotNodeAttributeSet ,
2222)
23- from metricflow_semantics .experimental .mf_graph .formatting .graph_formatter import MetricflowGraphFormatter
23+ from metricflow_semantics .experimental .mf_graph .formatting .graph_formatter import MetricFlowGraphFormatter
2424from metricflow_semantics .experimental .mf_graph .formatting .pretty_graph_formatter import PrettyFormatGraphFormatter
2525from metricflow_semantics .experimental .mf_graph .graph_element import (
26- MetricflowGraphElement ,
26+ MetricFlowGraphElement ,
2727)
28- from metricflow_semantics .experimental .mf_graph .graph_id import MetricflowGraphId
29- from metricflow_semantics .experimental .mf_graph .graph_labeling import MetricflowGraphLabel
30- from metricflow_semantics .experimental .mf_graph .node_descriptor import MetricflowGraphNodeDescriptor
28+ from metricflow_semantics .experimental .mf_graph .graph_id import MetricFlowGraphId
29+ from metricflow_semantics .experimental .mf_graph .graph_labeling import MetricFlowGraphLabel
30+ from metricflow_semantics .experimental .mf_graph .node_descriptor import MetricFlowGraphNodeDescriptor
3131from metricflow_semantics .experimental .ordered_set import FrozenOrderedSet , MutableOrderedSet , OrderedSet
3232from metricflow_semantics .mf_logging .format_option import PrettyFormatOption
3333from metricflow_semantics .mf_logging .lazy_formattable import LazyFormat
3939
4040logger = logging .getLogger (__name__ )
4141
42- NodeT = TypeVar ("NodeT" , bound = "MetricflowGraphNode " )
43- EdgeT = TypeVar ("EdgeT" , bound = "MetricflowGraphEdge " )
42+ NodeT = TypeVar ("NodeT" , bound = "MetricFlowGraphNode " )
43+ EdgeT = TypeVar ("EdgeT" , bound = "MetricFlowGraphEdge " )
4444
45- NodeT_co = TypeVar ("NodeT_co" , bound = "MetricflowGraphNode " , covariant = True )
46- EdgeT_co = TypeVar ("EdgeT_co" , bound = "MetricflowGraphEdge " , covariant = True )
45+ NodeT_co = TypeVar ("NodeT_co" , bound = "MetricFlowGraphNode " , covariant = True )
46+ EdgeT_co = TypeVar ("EdgeT_co" , bound = "MetricFlowGraphEdge " , covariant = True )
4747
4848
49- class MetricflowGraphNode ( MetricflowGraphElement , MetricFlowPrettyFormattable , Comparable , ABC ):
49+ class MetricFlowGraphNode ( MetricFlowGraphElement , MetricFlowPrettyFormattable , Comparable , ABC ):
5050 """Base class for nodes in a directed graph."""
5151
52- _DEFAULT_NODE_LABELS : ClassVar [OrderedSet [MetricflowGraphLabel ]] = FrozenOrderedSet ()
52+ _DEFAULT_NODE_LABELS : ClassVar [OrderedSet [MetricFlowGraphLabel ]] = FrozenOrderedSet ()
5353
5454 def as_dot_node (self , include_graphical_attributes : bool ) -> DotNodeAttributeSet :
5555 """Return this as attributes for a DOT node.
@@ -65,13 +65,13 @@ def as_dot_node(self, include_graphical_attributes: bool) -> DotNodeAttributeSet
6565
6666 @property
6767 @abstractmethod
68- def node_descriptor (self ) -> MetricflowGraphNodeDescriptor : # noqa: D102
68+ def node_descriptor (self ) -> MetricFlowGraphNodeDescriptor : # noqa: D102
6969 raise NotImplementedError
7070
7171 @property
72- def labels (self ) -> OrderedSet [MetricflowGraphLabel ]:
72+ def labels (self ) -> OrderedSet [MetricFlowGraphLabel ]:
7373 """Return the labels that can be used for lookups to get this node."""
74- return MetricflowGraphNode ._DEFAULT_NODE_LABELS
74+ return MetricFlowGraphNode ._DEFAULT_NODE_LABELS
7575
7676 @override
7777 def pretty_format (self , format_context : PrettyFormatContext ) -> Optional [str ]:
@@ -89,13 +89,13 @@ def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
8989
9090
9191@fast_frozen_dataclass (order = False )
92- class MetricflowGraphEdge ( MetricflowGraphElement , MetricFlowPrettyFormattable , Comparable , Generic [NodeT_co ], ABC ):
92+ class MetricFlowGraphEdge ( MetricFlowGraphElement , MetricFlowPrettyFormattable , Comparable , Generic [NodeT_co ], ABC ):
9393 """Base class for edges in a directed graph.
9494
9595 An edge can be visualized as an arrow that points from the tail node to the head node.
9696 """
9797
98- _DEFAULT_EDGE_LABELS : ClassVar [OrderedSet [MetricflowGraphLabel ]] = FrozenOrderedSet ()
98+ _DEFAULT_EDGE_LABELS : ClassVar [OrderedSet [MetricFlowGraphLabel ]] = FrozenOrderedSet ()
9999
100100 tail_node : NodeT_co
101101 head_node : NodeT_co
@@ -125,9 +125,9 @@ def as_dot_edge(self, include_graphical_attributes: bool) -> DotEdgeAttributeSet
125125 )
126126
127127 @property
128- def labels (self ) -> OrderedSet [MetricflowGraphLabel ]:
128+ def labels (self ) -> OrderedSet [MetricFlowGraphLabel ]:
129129 """Return the labels that can be used for lookups to get this edge."""
130- return MetricflowGraphEdge ._DEFAULT_EDGE_LABELS
130+ return MetricFlowGraphEdge ._DEFAULT_EDGE_LABELS
131131
132132 @override
133133 def pretty_format (self , format_context : PrettyFormatContext ) -> Optional [str ]:
@@ -144,15 +144,15 @@ def pretty_format(self, format_context: PrettyFormatContext) -> Optional[str]:
144144 )
145145
146146 @cached_property
147- def labels_for_path_addition (self ) -> OrderedSet [MetricflowGraphLabel ]:
147+ def labels_for_path_addition (self ) -> OrderedSet [MetricFlowGraphLabel ]:
148148 """Return the labels for this edge and the head node.
149149
150150 This is useful for collecting labels while building a path by adding an edge.
151151 """
152152 return self .labels .union (self .head_node .labels )
153153
154154
155- class MetricflowGraph (MetricFlowPrettyFormattable , Generic [NodeT_co , EdgeT_co ], ABC ):
155+ class MetricFlowGraph (MetricFlowPrettyFormattable , Generic [NodeT_co , EdgeT_co ], ABC ):
156156 """Base class for a directed graph."""
157157
158158 @property
@@ -162,11 +162,11 @@ def nodes(self) -> OrderedSet[NodeT_co]:
162162 raise NotImplementedError ()
163163
164164 @abstractmethod
165- def nodes_with_labels (self , * graph_labels : MetricflowGraphLabel ) -> OrderedSet [NodeT_co ]:
165+ def nodes_with_labels (self , * graph_labels : MetricFlowGraphLabel ) -> OrderedSet [NodeT_co ]:
166166 """Return nodes in the graph with any one of the given labels."""
167167 raise NotImplementedError ()
168168
169- def node_with_label (self , label : MetricflowGraphLabel ) -> NodeT_co :
169+ def node_with_label (self , label : MetricFlowGraphLabel ) -> NodeT_co :
170170 """Finds the node with the given label. If not exactly one if found, an error is raised."""
171171 nodes = self .nodes_with_labels (label )
172172 matching_node_count = len (nodes )
@@ -187,34 +187,34 @@ def edges(self) -> OrderedSet[EdgeT_co]:
187187 raise NotImplementedError ()
188188
189189 @abstractmethod
190- def edges_with_tail_node (self , tail_node : MetricflowGraphNode ) -> OrderedSet [EdgeT_co ]:
190+ def edges_with_tail_node (self , tail_node : MetricFlowGraphNode ) -> OrderedSet [EdgeT_co ]:
191191 """Returns edges with the given tail node."""
192192 raise NotImplementedError ()
193193
194194 @abstractmethod
195- def edges_with_head_node (self , tail_node : MetricflowGraphNode ) -> OrderedSet [EdgeT_co ]:
195+ def edges_with_head_node (self , tail_node : MetricFlowGraphNode ) -> OrderedSet [EdgeT_co ]:
196196 """Returns edges with the given head node."""
197197 raise NotImplementedError ()
198198
199199 @abstractmethod
200- def edges_with_label (self , label : MetricflowGraphLabel ) -> OrderedSet [EdgeT_co ]:
200+ def edges_with_label (self , label : MetricFlowGraphLabel ) -> OrderedSet [EdgeT_co ]:
201201 """Return the set of edges in a graph that have the given label."""
202202 raise NotImplementedError ()
203203
204- def format (self , formatter : MetricflowGraphFormatter = PrettyFormatGraphFormatter ()) -> str :
204+ def format (self , formatter : MetricFlowGraphFormatter = PrettyFormatGraphFormatter ()) -> str :
205205 """Return a representation of this graph using the given formatter."""
206206 return formatter .format_graph (self )
207207
208208 @abstractmethod
209- def successors (self , node : MetricflowGraphNode ) -> OrderedSet [NodeT_co ]:
209+ def successors (self , node : MetricFlowGraphNode ) -> OrderedSet [NodeT_co ]:
210210 """Returns successors of the given node.
211211
212212 Raises `UnknownNodeException` if the node does not exist in the graph.
213213 """
214214 return FrozenOrderedSet (edge .head_node for edge in self .edges_with_tail_node (node ))
215215
216216 @abstractmethod
217- def predecessors (self , node : MetricflowGraphNode ) -> OrderedSet [NodeT_co ]:
217+ def predecessors (self , node : MetricFlowGraphNode ) -> OrderedSet [NodeT_co ]:
218218 """Returns predecessors of the given node.
219219
220220 Raises `UnknownNodeException` if the node does not exist in the graph.
@@ -233,7 +233,7 @@ def as_sorted(self) -> Self:
233233 """Return a copy of this graph with the nodes and edges sorted."""
234234 raise NotImplementedError
235235
236- def _intersect_edges (self , other : MetricflowGraph [NodeT_co , EdgeT_co ]) -> OrderedSet [EdgeT_co ]:
236+ def _intersect_edges (self , other : MetricFlowGraph [NodeT_co , EdgeT_co ]) -> OrderedSet [EdgeT_co ]:
237237 return self .edges .intersection (other .edges )
238238
239239 @abstractmethod
@@ -267,7 +267,7 @@ def as_dot_graph(self, include_graphical_attributes: bool) -> DotGraphAttributeS
267267
268268 @property
269269 @abstractmethod
270- def graph_id (self ) -> MetricflowGraphId :
270+ def graph_id (self ) -> MetricFlowGraphId :
271271 """Return a graph ID.
272272
273273 This ID will be used for caching cases.
0 commit comments