Skip to content

Commit 898538d

Browse files
fixed plot CLI parsing of apply_pauli_frame (#4)
1 parent dbf66d5 commit 898538d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tesseract_sim/plotting/plot_acceptance_rates.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ def plot_ec_experiment(
123123
out_path=os.path.join(out_dir, f'logical_rates_{"channel" if sweep_channel_noise else "ec"}_noise_ec_experiment.png')
124124
)
125125

126+
def str_to_bool(v):
127+
"""Convert string to boolean for argparse."""
128+
if isinstance(v, bool):
129+
return v
130+
if v.lower() in ('yes', 'true', 't', 'y', '1'):
131+
return True
132+
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
133+
return False
134+
else:
135+
raise argparse.ArgumentTypeError('Boolean value expected.')
136+
126137
def main():
127138
parser = argparse.ArgumentParser(description="Generate acceptance rate plots for tesseract experiments")
128139
parser.add_argument('--experiments', type=int, nargs='+', choices=[2], default=[2],
@@ -131,7 +142,7 @@ def main():
131142
help='Number of shots per data point')
132143
parser.add_argument('--out-dir', type=str, default='../plots',
133144
help='Output directory for plots')
134-
parser.add_argument('--apply_pauli_frame', type=bool, default=False, help='Perform final correction - apply the measured Pauli frame. The error correction rounds and measurements (besides the actual correction at the end) happen regardless, based on the number of rounds.')
145+
parser.add_argument('--apply_pauli_frame', type=str_to_bool, default=False, help='Perform final correction - apply the measured Pauli frame. The error correction rounds and measurements (besides the actual correction at the end) happen regardless, based on the number of rounds.')
135146
parser.add_argument('--encoding-mode', type=str, choices=['9a', '9b'], default='9a', help='Encoding mode')
136147
parser.add_argument('--sweep-channel-noise', action='store_true', help='Sweep channel noise instead of EC noise. Channel noise acts once after encoding and before the error correction rounds.')
137148
args = parser.parse_args()

0 commit comments

Comments
 (0)