Skip to content

fix(plot_tune_summary): Skip empty full_band_resp from from_old_tune (#13) - #985

Open
ruck314 wants to merge 1 commit into
mainfrom
issues-13
Open

fix(plot_tune_summary): Skip empty full_band_resp from from_old_tune (#13)#985
ruck314 wants to merge 1 commit into
mainfrom
issues-13

Conversation

@ruck314

@ruck314 ruck314 commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #13. plot_tune_summary(band, eta_scan=True) crashes with KeyError: 'freq' when the loaded tune file contains an empty full_band_resp = {}.

The empty dict is written by tune_band_serial(from_old_tune=True): that path loads tune data from disk without running a fresh full-band sweep, but freq_resp[band]['full_band_resp'] = {} was assigned unconditionally and the empty dict was then persisted by save_tune(). On a later session, the existence check in plot_tune_summary (if 'full_band_resp' in self.freq_resp[band]) passed, but accessing ['freq'] raised.

Changes

  • tune_band_serial (smurf_tune.py:389-393): only assign full_band_resp when both freq and resp are populated. Prevents future tune files from carrying an empty dict.
  • plot_tune_summary (smurf_tune.py:533-541): also require the 'freq' and 'resp' subkeys before taking the full-band branch. Already-saved bad tune files fall through to the existing per-resonance freq_eta_scan / resp_eta_scan branch instead of raising.

Test plan

  • flake8 --count python/ — 0 errors (matches CI).
  • Smoke test of the patched predicates: confirmed pre-fix code reproduces KeyError('freq') on an empty full_band_resp, post-fix code falls through to the else branch and the populated-full_band_resp happy path is unchanged.
  • Full hardware exercise of plot_tune_summary(band, eta_scan=True) against a tune file produced by tune_band_serial(from_old_tune=True) — requires SMuRF hardware; not feasible from this checkout.

…13)

tune_band_serial(from_old_tune=True) loads tune data from disk without
running a fresh full-band sweep, but still wrote
self.freq_resp[band]['full_band_resp'] = {} unconditionally and
persisted the empty dict via save_tune(). On a later session,
plot_tune_summary(band, eta_scan=True) found the parent key, took the
full-band branch, and crashed with KeyError: 'freq' on the missing
subkeys.

- tune_band_serial: only assign full_band_resp when both freq and resp
  are populated, so future tune files no longer carry an empty dict.
- plot_tune_summary: also require the 'freq' and 'resp' subkeys before
  taking the full-band branch, so already-saved bad tune files fall
  through to the existing per-resonance freq_eta_scan/resp_eta_scan
  branch instead of raising.
@ruck314
ruck314 requested review from swh76 and tristpinsm as code owners May 1, 2026 21:58
@github-actions github-actions Bot added the client Changes to the client code label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Changes to the client code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to plot tune summary for loaded tune data

1 participant