Skip to content

Commit

Permalink
Guard against failed RB estimate in plots.
Browse files Browse the repository at this point in the history
  • Loading branch information
sserita committed Sep 20, 2023
1 parent fc4f1d5 commit 9070c0b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pygsti/report/workspaceplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3638,19 +3638,22 @@ def _create(self, rb_r, fitkey, decay, success_probabilities, ylim, xlim,

if decay:
lengths = _np.linspace(0, max(rb_r.depths), 200)
A = rb_r.fits[fitkey].estimates['a']
B = rb_r.fits[fitkey].estimates['b']
p = rb_r.fits[fitkey].estimates['p']

data.append(go.Scatter(
x=lengths,
y=A + B * p**lengths,
mode='lines',
line=dict(width=1, color="rgb(120,120,120)"),
name='Fit, r = {:.2} +/- {:.1}'.format(rb_r.fits[fitkey].estimates['r'],
rb_r.fits[fitkey].stds['r']),
showlegend=legend,
))
try:
A = rb_r.fits[fitkey].estimates['a']
B = rb_r.fits[fitkey].estimates['b']
p = rb_r.fits[fitkey].estimates['p']

data.append(go.Scatter(
x=lengths,
y=A + B * p**lengths,
mode='lines',
line=dict(width=1, color="rgb(120,120,120)"),
name='Fit, r = {:.2} +/- {:.1}'.format(rb_r.fits[fitkey].estimates['r'],
rb_r.fits[fitkey].stds['r']),
showlegend=legend,
))
except KeyError:
_warnings.warn(f'RB fit for {fitkey} likely failed, skipping plot...')

if success_probabilities:
all_success_probs_by_depth = [data_per_depth[depth] for depth in rb_r.depths]
Expand Down

0 comments on commit 9070c0b

Please sign in to comment.