From 9070c0b1deaa77bae5b709d0fa99f2a2c4252033 Mon Sep 17 00:00:00 2001 From: "Stefan K. Seritan" Date: Tue, 19 Sep 2023 17:44:27 -0700 Subject: [PATCH] Guard against failed RB estimate in plots. --- pygsti/report/workspaceplots.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pygsti/report/workspaceplots.py b/pygsti/report/workspaceplots.py index 3258d9c73..2baf6d888 100644 --- a/pygsti/report/workspaceplots.py +++ b/pygsti/report/workspaceplots.py @@ -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]