1919from qiskit .providers import Backend
2020from qiskit .circuit import QuantumCircuit
2121from qiskit .utils import apply_prefix
22+ from qiskit .providers .options import Options
2223
2324from qiskit_experiments .base_experiment import BaseExperiment
2425from qiskit_experiments .base_analysis import BaseAnalysis
2930
3031
3132class T1Analysis (BaseAnalysis ):
32- """T1 Experiment result analysis class."""
33+ """T1 Experiment result analysis class.
3334
34- # pylint: disable=arguments-differ, unused-argument
35+ Analysis Options:
36+ t1_guess (float): Optional, an initial guess of T1
37+ amplitude_guess (float): Optional, an initial guess of the coefficient of the exponent
38+ offset_guess (float): Optional, an initial guess of the offset
39+ t1_bounds (list of two floats): Optional, lower bound and upper bound to T1
40+ amplitude_bounds (list of two floats): Optional, lower bound and upper bound to the amplitude
41+ offset_bounds (list of two floats): Optional, lower bound and upper bound to the offset
42+ """
43+
44+ @classmethod
45+ def _default_options (cls ):
46+ return Options (
47+ t1_guess = None ,
48+ amplitude_guess = None ,
49+ offset_guess = None ,
50+ t1_bounds = None ,
51+ amplitude_bounds = None ,
52+ offset_bounds = None ,
53+ )
54+
55+ # pylint: disable=arguments-differ
3556 def _run_analysis (
3657 self ,
3758 experiment_data ,
@@ -41,10 +62,7 @@ def _run_analysis(
4162 t1_bounds = None ,
4263 amplitude_bounds = None ,
4364 offset_bounds = None ,
44- plot = True ,
45- ax = None ,
46- ** kwargs ,
47- ) -> Tuple [AnalysisResult , List ["plotting.pyplot.Figure" ]]:
65+ ) -> Tuple [AnalysisResult , None ]:
4866 """
4967 Calculate T1
5068
@@ -54,23 +72,15 @@ def _run_analysis(
5472 amplitude_guess (float): Optional, an initial guess of the coefficient
5573 of the exponent
5674 offset_guess (float): Optional, an initial guess of the offset
57- t1_bounds (list of two floats): Optional, lower bound and upper
58- bound to T1
59- amplitude_bounds (list of two floats): Optional, lower bound and
60- upper bound to the amplitude
61- offset_bounds (list of two floats): Optional, lower bound and upper
62- bound to the offset
63- plot: If True generate a plot of fitted data.
64- ax: Optional, matplotlib axis to add plot to.
65- kwargs: Trailing unused function parameters
75+ t1_bounds (list of two floats): Optional, lower bound and upper bound to T1
76+ amplitude_bounds (list of two floats): Optional, lower bound and upper bound to the amplitude
77+ offset_bounds (list of two floats): Optional, lower bound and upper bound to the offset
6678
6779 Returns:
6880 The analysis result with the estimated T1
6981 """
70- data = experiment_data .data ()
71- unit = data [0 ]["metadata" ]["unit" ]
72- conversion_factor = data [0 ]["metadata" ].get ("dt_factor" , None )
73- qubit = data [0 ]["metadata" ]["qubit" ]
82+ unit = experiment_data ._data [0 ]["metadata" ]["unit" ]
83+ conversion_factor = experiment_data ._data [0 ]["metadata" ].get ("dt_factor" , None )
7484 if conversion_factor is None :
7585 conversion_factor = 1 if unit == "s" else apply_prefix (1 , unit )
7686
@@ -190,6 +200,10 @@ class T1Experiment(BaseExperiment):
190200
191201 __analysis_class__ = T1Analysis
192202
203+ @classmethod
204+ def _default_options (cls ) -> Options :
205+ return Options (delays = None , unit = "s" )
206+
193207 def __init__ (
194208 self ,
195209 qubit : int ,
@@ -210,13 +224,9 @@ def __init__(
210224 """
211225 if len (delays ) < 3 :
212226 raise ValueError ("T1 experiment: number of delays must be at least 3" )
227+ super ().__init__ ([qubit ], delays = delays , unit = unit )
213228
214- self ._delays = delays
215- self ._unit = unit
216- super ().__init__ ([qubit ])
217-
218- # pylint: disable=arguments-differ
219- def circuits (self , backend : Optional [Backend ] = None ) -> List [QuantumCircuit ]:
229+ def circuits (self , backend : Optional ["Backend" ] = None ) -> List [QuantumCircuit ]:
220230 """
221231 Return a list of experiment circuits
222232
@@ -229,31 +239,30 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
229239 Raises:
230240 AttributeError: if unit is dt but dt parameter is missing in the backend configuration
231241 """
232-
233- if self ._unit == "dt" :
242+ if self .options .unit == "dt" :
234243 try :
235244 dt_factor = getattr (backend .configuration (), "dt" )
236245 except AttributeError as no_dt :
237246 raise AttributeError ("Dt parameter is missing in backend configuration" ) from no_dt
238247
239248 circuits = []
240249
241- for delay in self ._delays :
250+ for delay in self .options . delays :
242251 circ = QuantumCircuit (1 , 1 )
243252 circ .x (0 )
244253 circ .barrier (0 )
245- circ .delay (delay , 0 , self ._unit )
254+ circ .delay (delay , 0 , self .options . unit )
246255 circ .barrier (0 )
247256 circ .measure (0 , 0 )
248257
249258 circ .metadata = {
250259 "experiment_type" : self ._type ,
251260 "qubit" : self .physical_qubits [0 ],
252261 "xval" : delay ,
253- "unit" : self ._unit ,
262+ "unit" : self .options . unit ,
254263 }
255264
256- if self ._unit == "dt" :
265+ if self .options . unit == "dt" :
257266 circ .metadata ["dt_factor" ] = dt_factor
258267
259268 circuits .append (circ )
0 commit comments