33from ipywidgets import interactive , IntSlider # type: ignore
44from typing import List
55
6+
67def plot_circuit (component ):
78 """
89 Show the interactive component layout with iKlayout.
@@ -21,7 +22,9 @@ def plot_circuit(component):
2122 return iklayout .show (path )
2223
2324
24- def plot_losses (losses : List [float ], iterations : List [int ] | None = None , return_fig : bool = False ):
25+ def plot_losses (
26+ losses : List [float ], iterations : List [int ] | None = None , return_fig : bool = False
27+ ):
2528 """
2629 Plot a list of losses with labels.
2730
@@ -39,7 +42,12 @@ def plot_losses(losses: List[float], iterations: List[int] | None = None, return
3942 plt .show ()
4043
4144
42- def plot_constraints (constraints : List [List [float ]], constraints_labels : List [str ] | None = None , iterations : List [int ] | None = None , return_fig : bool = False ):
45+ def plot_constraints (
46+ constraints : List [List [float ]],
47+ constraints_labels : List [str ] | None = None ,
48+ iterations : List [int ] | None = None ,
49+ return_fig : bool = False ,
50+ ):
4351 """
4452 Plot a list of constraints with labels.
4553
@@ -48,7 +56,9 @@ def plot_constraints(constraints: List[List[float]], constraints_labels: List[st
4856 labels: List of labels for each constraint value.
4957 """
5058
51- constraints_labels = constraints_labels or [f"Constraint { i } " for i in range (len (constraints [0 ]))]
59+ constraints_labels = constraints_labels or [
60+ f"Constraint { i } " for i in range (len (constraints [0 ]))
61+ ]
5262 iterations = iterations or list (range (len (constraints [0 ])))
5363
5464 plt .figure (figsize = (10 , 5 ))
@@ -64,10 +74,12 @@ def plot_constraints(constraints: List[List[float]], constraints_labels: List[st
6474 plt .show ()
6575
6676
67- def plot_single_spectrum (spectrum : List [float ],
68- wavelengths : List [float ],
69- vlines : List [float ] | None = None ,
70- hlines : List [float ] | None = None ):
77+ def plot_single_spectrum (
78+ spectrum : List [float ],
79+ wavelengths : List [float ],
80+ vlines : List [float ] | None = None ,
81+ hlines : List [float ] | None = None ,
82+ ):
7183 """
7284 Plot a single spectrum with vertical and horizontal lines.
7385 """
@@ -157,5 +169,7 @@ def plot_array(index=0):
157169 plt .grid (True )
158170 plt .show ()
159171
160- slider = IntSlider (value = 0 , min = 0 , max = len (spectrums [0 ]) - 1 , step = 1 , description = "Index" )
172+ slider = IntSlider (
173+ value = 0 , min = 0 , max = len (spectrums [0 ]) - 1 , step = 1 , description = "Index"
174+ )
161175 return interactive (plot_array , index = slider )
0 commit comments