-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
return also syndrome and v_node validity from decoder (Sourcery refactored) #27
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,9 @@ def add_edges_by_uid(self, edges_set: EdgesSet) -> None: | |
""" | ||
for v_uid, c_uid in edges_set: | ||
if v_uid not in self.v_nodes: | ||
raise ValueError("No v-node with uid " + str(v_uid) + " in graph") | ||
raise ValueError(f"No v-node with uid {str(v_uid)} in graph") | ||
if c_uid not in self.c_nodes: | ||
raise ValueError("No c-node with uid " + str(c_uid) + " in graph") | ||
raise ValueError(f"No c-node with uid {str(c_uid)} in graph") | ||
self.add_edge(v_uid, c_uid) | ||
|
||
def add_edges_by_name(self, edges_set: set[tuple[str, str]]) -> None: | ||
|
@@ -68,20 +68,25 @@ def add_edges_by_name(self, edges_set: set[tuple[str, str]]) -> None: | |
for v_name, c_name in edges_set: | ||
v_uid = [node.uid for node in self.v_nodes.values() if node.name == v_name] | ||
if not v_uid: | ||
raise ValueError("No v-node with name " + v_name + " in graph") | ||
raise ValueError(f"No v-node with name {v_name} in graph") | ||
c_uid = [node.uid for node in self.c_nodes.values() if node.name == c_name] | ||
if not c_uid: | ||
raise ValueError("No c-node with name " + c_name + " in graph") | ||
raise ValueError(f"No c-node with name {c_name} in graph") | ||
Comment on lines
-71
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self.add_edge(v_uid[0], c_uid[0]) | ||
|
||
def get_edges(self, by_name: bool = False) -> Union[set[tuple[str, str]], EdgesSet]: | ||
""" | ||
:param by_name: if true nodes are referred to by name, otherwise by uid. Default to false | ||
:return: returns a set of edges. if by_name each element is a tuple of node names, else it is a tuple of uid. | ||
""" | ||
if not by_name: | ||
return self.edges | ||
return {(self.v_nodes.get(vn).name, self.c_nodes.get(cn).name) for vn, cn in self.edges} # type: ignore | ||
return ( | ||
{ | ||
(self.v_nodes.get(vn).name, self.c_nodes.get(cn).name) | ||
for vn, cn in self.edges | ||
} | ||
if by_name | ||
else self.edges | ||
) | ||
Comment on lines
-82
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
||
|
||
def to_nx(self) -> nx.Graph: | ||
"""Transform a TannerGraph object into an networkx.Graph object""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
TannerGraph.add_edges_by_uid
refactored with the following changes:use-fstring-for-concatenation
)