0
$\begingroup$

I'm using stim and sinter and can't figure out how to pass multiple arguments to sinter plot --filter_func. A single argument works as

--filter_func "metadata['d']<8".

I've tried passing multiple arguments a few different ways, e.g.

--filter_func "metadata['d']<8" "metadata['b']=='x'"

--filter_func "metadata['d']<8" --filter_func "metadata['b']=='x'"

But can't get it to work so I'm wondering how.

My whole process is: first I use the terminal to collect some statistics on different distance surface codes using stim and sinter:

mkdir circuits;
python3 -c "
import stim

for p in [0.002]:
    for d in [3, 5, 7, 9]:
      for b in 'xz':
        with open(f'circuits/d={d},p={p},b={b}.stim', 'w') as f:
            c = stim.Circuit.generated(
                rounds=d,
                distance=d,
                after_clifford_depolarization=p,
                after_reset_flip_probability=p,
                before_measure_flip_probability=p,
                before_round_data_depolarization=p,
                code_task=f'surface_code:rotated_memory_{b}')
            print(c, file=f)
";

sinter collect \
    --processes 4  \
    --circuits circuits/*.stim \
    --metadata_func "auto" \
    --decoders pymatching \
    --max_shots 100_000_000 \
    --max_errors 1000 \
    --save_resume_filepath stats.csv

And then I plot it using sinter plot. I could specify that I only want to plot up to distance 7 even though I collected data up to distance 9 using --filter_func "metadata['d']<8"

sinter plot  \
    --in  stats.csv \
    --group_func "f'''p={metadata['p']} b={metadata['b']}'''"\
    --x_func "metadata['d']"  \
    --xaxis "Distance" \
    --filter_func "metadata['d']<8" \
    --show \
    --out plot.png

Which gives this plot: enter image description here

However I don't know how to specify two filters, like only plotting up to distance 7 and only plotting the b=x line.

$\endgroup$

1 Answer 1

0
$\begingroup$

The --filter_func argument is an arbitrary python expression. In python you combine conditions using and. In your case, that means you want this:

--filter_func "metadata['d']<8 and metadata['b']=='x'"

(All the arguments that end in _func are python expression arguments. Internally they are prefixed with lambda various_args, etc: , then compiled using python's compile built-in.)

$\endgroup$
1
  • $\begingroup$ Perfect thank you! $\endgroup$
    – drumadoir
    Commented Jul 19, 2023 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.