@@ -292,9 +292,7 @@ def _native_or(name, fallback):
292292# `_py_generate_parity_check_matrix` has always existed as its pure-Python
293293# fallback, but neither was ever bound to a module-level name -- so the native
294294# function was unreachable from Python and the fallback was dead code.
295- py_generate_parity_check_matrix = _native_or (
296- "py_generate_parity_check_matrix" , _py_generate_parity_check_matrix
297- )
295+ py_generate_parity_check_matrix = _native_or ("py_generate_parity_check_matrix" , _py_generate_parity_check_matrix )
298296
299297
300298def _py_estimate_distance (check_to_qubits , n_qubits = None ):
@@ -350,7 +348,9 @@ def _py_estimate_distance(check_to_qubits, n_qubits=None):
350348except AttributeError :
351349
352350 def run_mcp_server (* args , ** kwargs ):
353- raise RuntimeError ("The native core does not export run_mcp_server. This is likely a build mismatch — rebuild with 'maturin develop' to include the MCP server." )
351+ raise RuntimeError (
352+ "The native core does not export run_mcp_server. This is likely a build mismatch — rebuild with 'maturin develop' to include the MCP server."
353+ )
354354
355355
356356try :
@@ -916,9 +916,7 @@ def batch_decode_weighted(self, syndromes, weights):
916916 if weights .ndim != 2 :
917917 raise ValueError (f"weights must be 2D, got shape { weights .shape } " )
918918 if syndromes .shape [0 ] != weights .shape [0 ]:
919- raise ValueError (
920- f"syndromes batch { syndromes .shape [0 ]} != weights batch { weights .shape [0 ]} "
921- )
919+ raise ValueError (f"syndromes batch { syndromes .shape [0 ]} != weights batch { weights .shape [0 ]} " )
922920 return self ._inner .batch_decode_weighted (syndromes , weights )
923921
924922 @property
@@ -953,9 +951,7 @@ def __init__(
953951 p_meas = None ,
954952 ):
955953 c2q , nq = _validate_check_to_qubits (check_to_qubits , n_qubits )
956- self ._inner = _RustSlidingWindowDecoder (
957- c2q , nq , window_size , decay_factor , check_types , p_data , p_meas
958- )
954+ self ._inner = _RustSlidingWindowDecoder (c2q , nq , window_size , decay_factor , check_types , p_data , p_meas )
959955
960956 def update (self , round_syndrome ):
961957 if not isinstance (round_syndrome , _np .ndarray ):
@@ -1027,9 +1023,7 @@ def __init__(
10271023 p_meas = None ,
10281024 ):
10291025 c2q , nq = _validate_check_to_qubits (check_to_qubits , n_qubits )
1030- self ._inner = _RustStreamingDecoder (
1031- c2q , nq , history_size , check_types , p_data , p_meas
1032- )
1026+ self ._inner = _RustStreamingDecoder (c2q , nq , history_size , check_types , p_data , p_meas )
10331027
10341028 def update (self , round_syndrome ):
10351029 if not isinstance (round_syndrome , _np .ndarray ):
@@ -2125,9 +2119,10 @@ def from_circuit(circuit, decoder_type="blossom", **kwargs):
21252119 Example::
21262120
21272121 import stim, qector_decoder_v3 as qector
2122+
21282123 circuit = stim.Circuit.generated(
2129- "surface_code:rotated_memory_x", distance=5, rounds=5,
2130- after_clifford_depolarization=0.001 )
2124+ "surface_code:rotated_memory_x", distance=5, rounds=5, after_clifford_depolarization=0.001
2125+ )
21312126 decoder = qector.from_circuit(circuit, decoder_type="belief_match")
21322127 samples = circuit.compile_detector_sampler().sample(100)[0]
21332128 predictions = decoder.decode_batch(samples)
@@ -2145,6 +2140,7 @@ def from_circuit(circuit, decoder_type="blossom", **kwargs):
21452140 # outright at d>=5. This branch must run before any
21462141 # decompose_errors=True call.
21472142 from .colour_code import ColourCodeDecoder
2143+
21482144 return ColourCodeDecoder .from_stim_circuit (circuit , ** kwargs )
21492145
21502146 dem = circuit .detector_error_model (decompose_errors = True )
@@ -2159,9 +2155,11 @@ def from_circuit(circuit, decoder_type="blossom", **kwargs):
21592155 return BPOSDDecoder (c2q , nq , ** kwargs )
21602156 if dt in ("beliefmatch" , "belief_matching" ):
21612157 from .belief_matching import BeliefMatching
2158+
21622159 return BeliefMatching .from_detector_error_model (dem , ** kwargs )
21632160 if dt in ("auto" ,):
21642161 from .backend import AutoDecoder
2162+
21652163 return AutoDecoder (c2q , nq , ** kwargs )
21662164 if dt in ("twostage" , "two_stage" , "correlated" , "c1_03" ):
21672165 # Default to blossom for both stages; pass check_types via kwargs or
0 commit comments