@@ -55,7 +55,10 @@ class TwoQubitXEBResult:
5555
5656 @functools .cached_property
5757 def _qubit_pair_map (self ) -> Dict [Tuple ['cirq.GridQubit' , 'cirq.GridQubit' ], int ]:
58- return {idx [- 1 ]: i for i , idx in enumerate (self .fidelities .index )}
58+ return {
59+ (min (q0 , q1 ), max (q0 , q1 )): i
60+ for i , (_ , _ , (q0 , q1 )) in enumerate (self .fidelities .index )
61+ }
5962
6063 @functools .cached_property
6164 def all_qubit_pairs (self ) -> Tuple [Tuple ['cirq.GridQubit' , 'cirq.GridQubit' ], ...]:
@@ -103,9 +106,7 @@ def plot_fitted_exponential(
103106 show_plot = not ax
104107 if not ax :
105108 fig , ax = plt .subplots (1 , 1 , figsize = (8 , 8 ))
106- if q0 > q1 :
107- q0 , q1 = q1 , q0
108- record = self .fidelities .iloc [self ._qubit_pair_map [(q0 , q1 )]]
109+ record = self ._record (q0 , q1 )
109110
110111 plt .axhline (1 , color = 'grey' , ls = '--' )
111112 plt .plot (record ['cycle_depths' ], record ['fidelities' ], 'o' )
@@ -125,11 +126,14 @@ def plot_fitted_exponential(
125126 if show_plot :
126127 fig .show ()
127128
128- def xeb_error (self , q0 : 'cirq.GridQubit' , q1 : 'cirq.GridQubit' ) -> float :
129- """Return the XEB error of a qubit pair."""
129+ def _record (self , q0 , q1 ) -> pd .Series :
130130 if q0 > q1 :
131131 q0 , q1 = q1 , q0
132- p = self .fidelities .layer_fid .iloc [self ._qubit_pair_map [(q0 , q1 )]]
132+ return self .fidelities .iloc [self ._qubit_pair_map [(q0 , q1 )]]
133+
134+ def xeb_error (self , q0 : 'cirq.GridQubit' , q1 : 'cirq.GridQubit' ) -> float :
135+ """Return the XEB error of a qubit pair."""
136+ p = self ._record (q0 , q1 ).layer_fid
133137 return 1 - p
134138
135139
0 commit comments