Skip to content

Commit

Permalink
fix: Fix plotting issues for CZ
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Mar 20, 2024
1 parent c171ad9 commit e692e3e
Showing 1 changed file with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ class CZVirtualZResults(Results):
virtual_phase: dict[QubitPairId, dict[QubitId, float]]
"""Virtual Z phase correction."""

def __contains__(self, key: QubitPairId):
"""Check if key is in class.
While key is a QubitPairId both chsh and chsh_mitigated contain
an additional key which represents the basis chosen.
"""

return key in [
(target, control) for target, control, _ in self.fitted_parameters
]


CZVirtualZType = np.dtype([("target", np.float64), ("control", np.float64)])

Expand Down Expand Up @@ -309,7 +319,7 @@ def _plot(data: CZVirtualZData, fit: CZVirtualZResults, target: QubitPairId):
f"Qubit {qubits[1]}",
),
)
reports = []
fitting_report = set()
fig2 = make_subplots(
rows=1,
cols=2,
Expand All @@ -319,7 +329,6 @@ def _plot(data: CZVirtualZData, fit: CZVirtualZResults, target: QubitPairId):
),
)

fitting_report = ""
thetas = data.thetas
for target_q, control_q, setup in pair_data:
target_prob = pair_data[target_q, control_q, setup].target
Expand Down Expand Up @@ -363,19 +372,23 @@ def _plot(data: CZVirtualZData, fit: CZVirtualZResults, target: QubitPairId):
col=1 if fig == fig1 else 2,
)

fitting_report = table_html(
table_dict(
[target_q, target_q, qubits[1]],
[
"CZ angle [rad]",
"Virtual Z phase [rad]",
"Flux pulse amplitude [a.u.]",
],
[
np.round(fit.cz_angle[target_q, control_q], 4),
np.round(fit.virtual_phase[tuple(sorted(target))][target_q], 4),
np.round(data.amplitudes[qubits]),
],
fitting_report.add(
table_html(
table_dict(
[target_q, target_q, qubits[1]],
[
"CZ angle [rad]",
"Virtual Z phase [rad]",
"Flux pulse amplitude [a.u.]",
],
[
np.round(fit.cz_angle[target_q, control_q], 4),
np.round(
fit.virtual_phase[tuple(sorted(target))][target_q], 4
),
np.round(data.amplitudes[qubits]),
],
)
)
)

Expand All @@ -395,7 +408,7 @@ def _plot(data: CZVirtualZData, fit: CZVirtualZResults, target: QubitPairId):
yaxis_title="Signal [a.u.]",
)

return [fig1, fig2], fitting_report
return [fig1, fig2], "".join(fitting_report) # target and control qubit


def _update(results: CZVirtualZResults, platform: Platform, target: QubitPairId):
Expand Down

0 comments on commit e692e3e

Please sign in to comment.