From 235fe9711c35aca5e5bc7ebba4d0a2dadaebd11d Mon Sep 17 00:00:00 2001 From: James Wootton Date: Thu, 21 Dec 2023 10:13:22 +0100 Subject: [PATCH] linting --- src/qiskit_qec/decoders/pymatching_decoder.py | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/qiskit_qec/decoders/pymatching_decoder.py b/src/qiskit_qec/decoders/pymatching_decoder.py index b61d26b4..32d86f83 100644 --- a/src/qiskit_qec/decoders/pymatching_decoder.py +++ b/src/qiskit_qec/decoders/pymatching_decoder.py @@ -33,20 +33,19 @@ def __init__(self, decoding_graph: DecodingGraph): """Setting up the matching object""" self.decoding_graph = decoding_graph self.graph = decoding_graph.graph - self.pymatching = self.matching() + self.pymatching = self._matching() self.indexer = None super().__init__() - def matching(self) -> Matching: + def _matching(self) -> Matching: return Matching(self.graph) - def logical_flips( - self, syndrome: Union[List[DecodingGraphNode], List[int]] - ) -> List[int]: + def logical_flips(self, syndrome: Union[List[DecodingGraphNode], List[int]]) -> List[int]: """ Args: - syndromes: a) list of DecodingGraphNode objects returnes by string2nodes, or - b) list of binaries indicating which node is highlighted, e.g., the output of a stim detector sampler + syndrome: Either a list of DecodingGraphNode objects returnes by string2nodes, + or a list of binaries indicating which node is highlighted, e.g., + the output of a stim detector sampler Returns: list of binaries indicating which logical is flipped """ if isinstance(syndrome[0], DecodingGraphNode): @@ -64,9 +63,7 @@ def process(self, string: str) -> List[int]: logical_flips = self.logical_flips(nodes) - corrected_logicals = [ - (raw + flip) % 2 for raw, flip in zip(raw_logicals, logical_flips) - ] + corrected_logicals = [(raw + flip) % 2 for raw, flip in zip(raw_logicals, logical_flips)] return corrected_logicals @@ -75,8 +72,8 @@ def matched_edges( ) -> List[DecodingGraphEdge]: """ Args: - syndromes: a) list of DecodingGraphNode objects returnes by string2nodes, or - b) list of binaries indicating which node is highlighted + syndrome: Either a list of DecodingGraphNode objects returnes by string2nodes, + or a list of binaries indicating which node is highlighted. Returns: list of DecodingGraphEdge-s included in the matching """ if isinstance(syndrome[0], DecodingGraphNode):