File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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 ))]
You can’t perform that action at this time.
0 commit comments