Skip to content

Commit

Permalink
refactor: Platform -> CalibrationPlatform + drop virtual_z_signal
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Nov 15, 2024
1 parent af4cfcb commit c280398
Show file tree
Hide file tree
Showing 56 changed files with 276 additions and 384 deletions.
2 changes: 0 additions & 2 deletions src/qibocal/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
chevron,
chevron_signal,
correct_virtual_z_phases,
correct_virtual_z_phases_signal,
optimize_two_qubit_gate,
)
from .two_qubit_state_tomography import two_qubit_state_tomography
Expand Down Expand Up @@ -93,7 +92,6 @@
"chevron",
"chevron_signal",
"correct_virtual_z_phases",
"correct_virtual_z_phases_signal",
"state_tomography",
"allxy_resonator_depletion_tuning",
"two_qubit_state_tomography",
Expand Down
7 changes: 4 additions & 3 deletions src/qibocal/protocols/allxy/allxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Delay, Platform, PulseSequence
from qibolab import AcquisitionType, AveragingMode, Delay, PulseSequence

from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform


@dataclass
Expand Down Expand Up @@ -64,7 +65,7 @@ class AllXYData(Data):

def _acquisition(
params: AllXYParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> AllXYData:
r"""
Expand Down Expand Up @@ -124,7 +125,7 @@ def _acquisition(


def allxy_sequence(
platform: Platform,
platform: CalibrationPlatform,
gates,
qubit,
sequence_delay=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AveragingMode, Platform, PulseSequence
from qibolab import AveragingMode, PulseSequence

from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform

from . import allxy

Expand Down Expand Up @@ -54,7 +55,7 @@ def delay_params(self):

def _acquisition(
params: AllXYResonatorParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> AllXYResonatorData:
r"""
Expand Down
9 changes: 6 additions & 3 deletions src/qibocal/protocols/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy.typing as npt
import pandas as pd
import plotly.graph_objects as go
from qibolab import AcquisitionType, Platform, PulseSequence
from qibolab import AcquisitionType, PulseSequence
from sklearn.metrics import roc_auc_score, roc_curve

from qibocal import update
Expand All @@ -20,6 +20,7 @@
Routine,
)
from qibocal.auto.serialize import serialize
from qibocal.calibration import CalibrationPlatform
from qibocal.fitting.classifier import run
from qibocal.protocols.utils import (
LEGEND_FONT_SIZE,
Expand Down Expand Up @@ -151,7 +152,7 @@ def save(self, path):

def _acquisition(
params: SingleShotClassificationParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> SingleShotClassificationData:
"""
Expand Down Expand Up @@ -396,7 +397,9 @@ def _plot(


def _update(
results: SingleShotClassificationResults, platform: Platform, target: QubitId
results: SingleShotClassificationResults,
platform: CalibrationPlatform,
target: QubitId,
):
update.iq_angle(results.rotation_angle[target], platform, target)
update.threshold(results.threshold[target], platform, target)
Expand Down
5 changes: 3 additions & 2 deletions src/qibocal/protocols/coherence/spin_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import numpy as np
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper
from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper

from qibocal.auto.operation import QubitId, Routine
from qibocal.calibration import CalibrationPlatform
from qibocal.result import probability

from ..utils import table_dict, table_html
Expand Down Expand Up @@ -35,7 +36,7 @@ class SpinEchoData(t1.T1Data):

def _acquisition(
params: SpinEchoParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> SpinEchoData:
"""Data acquisition for SpinEcho"""
Expand Down
9 changes: 6 additions & 3 deletions src/qibocal/protocols/coherence/spin_echo_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import numpy as np
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper
from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper

from qibocal.auto.operation import Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform
from qibocal.result import magnitude, phase

from ... import update
Expand Down Expand Up @@ -47,7 +48,7 @@ class SpinEchoSignalData(T1SignalData):

def _acquisition(
params: SpinEchoSignalParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> SpinEchoSignalData:
"""Data acquisition for SpinEcho"""
Expand Down Expand Up @@ -172,7 +173,9 @@ def _plot(data: SpinEchoSignalData, target: QubitId, fit: SpinEchoSignalResults
return figures, fitting_report


def _update(results: SpinEchoSignalResults, platform: Platform, target: QubitId):
def _update(
results: SpinEchoSignalResults, platform: CalibrationPlatform, target: QubitId
):
update.t2_spin_echo(results.t2_spin_echo[target], platform, target)


Expand Down
5 changes: 3 additions & 2 deletions src/qibocal/protocols/coherence/t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper
from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper

from qibocal.auto.operation import Data, QubitId, Routine
from qibocal.calibration import CalibrationPlatform
from qibocal.result import probability

from ..utils import table_dict, table_html
Expand Down Expand Up @@ -44,7 +45,7 @@ class T1Data(Data):


def _acquisition(
params: T1Parameters, platform: Platform, targets: list[QubitId]
params: T1Parameters, platform: CalibrationPlatform, targets: list[QubitId]
) -> T1Data:
"""Data acquisition for T1 experiment."""

Expand Down
8 changes: 4 additions & 4 deletions src/qibocal/protocols/coherence/t1_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
AveragingMode,
Delay,
Parameter,
Platform,
PulseSequence,
Sweeper,
)

from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform
from qibocal.result import magnitude, phase

from ... import update
Expand Down Expand Up @@ -63,7 +63,7 @@ def average(self):


def t1_sequence(
platform: Platform, targets: list[QubitId], delay: Optional[int] = None
platform: CalibrationPlatform, targets: list[QubitId], delay: Optional[int] = None
):
"""Create sequence for T1 experiment with a given optional delay."""
sequence = PulseSequence()
Expand All @@ -88,7 +88,7 @@ def t1_sequence(


def _acquisition(
params: T1SignalParameters, platform: Platform, targets: list[QubitId]
params: T1SignalParameters, platform: CalibrationPlatform, targets: list[QubitId]
) -> T1SignalData:
"""Data acquisition for T1 experiment.
Expand Down Expand Up @@ -207,7 +207,7 @@ def _plot(data: T1SignalData, target: QubitId, fit: T1SignalResults = None):
return figures, fitting_report


def _update(results: T1SignalResults, platform: Platform, target: QubitId):
def _update(results: T1SignalResults, platform: CalibrationPlatform, target: QubitId):
update.t1(results.t1[target], platform, target)


Expand Down
5 changes: 3 additions & 2 deletions src/qibocal/protocols/coherence/t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import numpy as np
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper
from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper

from qibocal.auto.operation import QubitId, Routine
from qibocal.calibration import CalibrationPlatform

from ...result import probability
from ..ramsey.utils import ramsey_sequence
Expand Down Expand Up @@ -41,7 +42,7 @@ class T2Data(t1.T1Data):

def _acquisition(
params: T2Parameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> T2Data:
"""Data acquisition for T2 experiment."""
Expand Down
7 changes: 4 additions & 3 deletions src/qibocal/protocols/coherence/t2_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import numpy as np
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper
from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper

from qibocal import update
from qibocal.auto.operation import Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform

from ...result import magnitude, phase
from ..ramsey.utils import ramsey_sequence
Expand Down Expand Up @@ -51,7 +52,7 @@ class T2SignalData(t1_signal.T1SignalData):

def _acquisition(
params: T2SignalParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> T2SignalData:
"""Data acquisition for T2 experiment.
Expand Down Expand Up @@ -174,7 +175,7 @@ def _plot(data: T2SignalData, target: QubitId, fit: T2SignalResults = None):
return figures, fitting_report


def _update(results: T2SignalResults, platform: Platform, target: QubitId):
def _update(results: T2SignalResults, platform: CalibrationPlatform, target: QubitId):
update.t2(results.t2[target], platform, target)


Expand Down
9 changes: 5 additions & 4 deletions src/qibocal/protocols/coherence/zeno.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import numpy as np
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, Platform, PulseSequence, Readout
from qibolab import AcquisitionType, AveragingMode, PulseSequence, Readout

from qibocal import update
from qibocal.auto.operation import Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform

from ...result import probability
from ..utils import table_dict, table_html
Expand Down Expand Up @@ -36,7 +37,7 @@ class ZenoResults(Results):


def zeno_sequence(
platform: Platform, targets: list[QubitId], readouts: int
platform: CalibrationPlatform, targets: list[QubitId], readouts: int
) -> tuple[PulseSequence, dict[QubitId, int]]:
"""Generating sequence for Zeno experiment."""

Expand All @@ -62,7 +63,7 @@ class ZenoData(t1.T1Data):

def _acquisition(
params: ZenoParameters,
platform: Platform,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> ZenoData:
"""
Expand Down Expand Up @@ -199,7 +200,7 @@ def _plot(data: ZenoData, fit: ZenoResults, target: QubitId):
return figures, fitting_report


def _update(results: ZenoResults, platform: Platform, qubit: QubitId):
def _update(results: ZenoResults, platform: CalibrationPlatform, qubit: QubitId):
update.t1(results.zeno_t1[qubit], platform, qubit)


Expand Down
20 changes: 9 additions & 11 deletions src/qibocal/protocols/dispersive_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
import numpy.typing as npt
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from qibolab import (
AcquisitionType,
AveragingMode,
Parameter,
Platform,
PulseSequence,
Sweeper,
)
from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper

from qibocal import update
from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine
from qibocal.calibration import CalibrationPlatform
from qibocal.protocols.utils import (
HZ_TO_GHZ,
lorentzian,
Expand Down Expand Up @@ -79,7 +73,9 @@ class DispersiveShiftData(Data):


def _acquisition(
params: DispersiveShiftParameters, platform: Platform, targets: list[QubitId]
params: DispersiveShiftParameters,
platform: CalibrationPlatform,
targets: list[QubitId],
) -> DispersiveShiftData:
r"""
Data acquisition for dispersive shift experiment.
Expand All @@ -88,7 +84,7 @@ def _acquisition(
Args:
params (DispersiveShiftParameters): experiment's parameters
platform (Platform): Qibolab platform object
platform (CalibrationPlatform): Qibolab platform object
targets (list): list of target qubits to perform the action
"""

Expand Down Expand Up @@ -322,7 +318,9 @@ def _plot(data: DispersiveShiftData, target: QubitId, fit: DispersiveShiftResult
return figures, fitting_report


def _update(results: DispersiveShiftResults, platform: Platform, target: QubitId):
def _update(
results: DispersiveShiftResults, platform: CalibrationPlatform, target: QubitId
):
update.readout_frequency(results.best_freq[target], platform, target)
if results.frequencies[target] is not None:
delta = (
Expand Down
Loading

0 comments on commit c280398

Please sign in to comment.