Skip to content

Commit e3bc194

Browse files
committed
minor fixes
1 parent 603d261 commit e3bc194

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ def plot_interactive_spectra(
121121

122122
# Defaults
123123
if spectrum_labels is None and isinstance(spectra, dict):
124-
if isinstance(list(spectra.keys())[0], str) and all("," in key for key in spectra.keys()):
124+
if all(isinstance(key, str) and "," in key for key in spectra.keys()):
125+
spectrum_labels = [f"T {ports.split(',')[0]} -> {ports.split(',')[1]}" for ports in spectra.keys()]
126+
elif all(isinstance(key, tuple) and len(key) == 2 for key in spectra.keys()):
125127
spectrum_labels = [f"T {port_in} -> {port_out}" for port_in, port_out in spectra.keys()]
126-
elif isinstance(list(spectra.keys())[0], tuple) and len(list(spectra.keys())[0]) == 2:
127-
spectrum_labels = [f"T {port_in} -> {port_out}" for port_in, port_out in spectra.keys()]
128+
else:
129+
raise ValueError("Invalid keys for spectra dictionary.")
128130

129131
elif spectrum_labels is None:
130132
spectrum_labels = [f"Spectrum {i}" for i in range(len(spectra))]

0 commit comments

Comments
 (0)