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

return also syndrome and v_node validity from decoder (Sourcery refactored) #27

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 12 additions & 7 deletions ldpc/decoder/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Comment on lines -58 to +60
Copy link
Author

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:

self.add_edge(v_uid, c_uid)

def add_edges_by_name(self, edges_set: set[tuple[str, str]]) -> None:
Expand All @@ -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
Copy link
Author

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_name refactored with the following changes:

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TannerGraph.get_edges refactored with the following changes:

This removes the following comments ( why? ):

# type: ignore


def to_nx(self) -> nx.Graph:
"""Transform a TannerGraph object into an networkx.Graph object"""
Expand Down