def test_planar_mps_decoder_small_code_negative_coset_probability(chi, mode): # parameters code = PlanarCode(3, 3) decoder = PlanarMPSDecoder(chi=chi, mode=mode) error_model = DepolarizingErrorModel() error_probability = 0.1 # logged run values error = pt.unpack(["e0048000", 26]) syndrome = pt.bsp(error, code.stabilizers.T) # debug print() print(code.ascii_art(syndrome, code.new_pauli(error))) # decode prob_dist = error_model.probability_distribution(error_probability) any_recovery = decoder.sample_recovery(code, syndrome) # coset probabilities coset_ps, recoveries = decoder._coset_probabilities( prob_dist, any_recovery) print('chi={}, mode={}, coset_ps={}'.format(chi, mode, coset_ps)) max_coset_p, max_recovery = max( zip(coset_ps, recoveries), key=lambda coset_p_recovery: coset_p_recovery[0]) success = np.all( pt.bsp(max_recovery.to_bsf() ^ error, code.logicals.T) == 0) print('### success=', success) assert mp.isfinite( max_coset_p ) and max_coset_p > 0, 'Max coset probability not as expected' assert np.all( np.array(coset_ps) >= 0), 'At least one coset probability is negative'
def test_biased_depolarising_error_model_probability_distribution_bias_half(): for axis in 'XYZ': bias = 0.5 error_model = BiasedDepolarizingErrorModel(bias, axis) depolarizing_error_model = DepolarizingErrorModel() p = 0.1 assert error_model.probability_distribution(p) == depolarizing_error_model.probability_distribution(p), ( 'Biased-depolarizing probability (bias=0.5) does not match standard depolarizing probability distribution.')