Skip to content

Commit

Permalink
refactor: Slightly rearrange import structure, clarify scope
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Jan 24, 2025
1 parent f3e82dc commit d7eb614
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
12 changes: 3 additions & 9 deletions src/qibolab/_core/instruments/qblox/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
from qibolab._core.execution_parameters import AcquisitionType, ExecutionParameters
from qibolab._core.identifier import ChannelId, Result
from qibolab._core.instruments.abstract import Controller
from qibolab._core.pulses import PulseId
from qibolab._core.sequence import PulseSequence
from qibolab._core.sweeper import ParallelSweepers

from . import config
from .config import PortAddress, SeqeuencerMap, SlotId
from .log import Logger
from .sequence import Sequence, compile
from .sequence.acquisition import AcquiredData
from .sequence import Sequence, acquisition, compile

__all__ = ["Cluster"]

Expand Down Expand Up @@ -103,7 +101,7 @@ def play(
log.status(self.cluster, sequencers)
data = self._execute(sequencers, options.estimate_duration([ps], sweepers))
log.data(data)
results |= _extract(data)
results |= acquisition.extract(data)
return results

def _configure(
Expand Down Expand Up @@ -135,7 +133,7 @@ def _configure(

def _execute(
self, sequencers: SeqeuencerMap, duration: float
) -> dict[ChannelId, AcquiredData]:
) -> dict[ChannelId, acquisition.AcquiredData]:
for mod, seqs in sequencers.items():
module = self._modules[mod]
for seq in seqs.values():
Expand All @@ -151,7 +149,3 @@ def _execute(
acquisitions[ch] = self.cluster.get_acquisitions(slot, seq)

return acquisitions


def _extract(acquisitions: dict[ChannelId, dict]) -> dict[PulseId, Result]:
return {}
2 changes: 2 additions & 0 deletions src/qibolab/_core/instruments/qblox/sequence/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from . import acquisition as acquisition
from . import program, sequence
from .program import *
from .sequence import *
from .sequence import compile as compile

__all__ = []
__all__ += program.__all__
Expand Down
14 changes: 11 additions & 3 deletions src/qibolab/_core/instruments/qblox/sequence/acquisition.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
from typing import TypedDict

from qibolab._core import pulses
from qibolab._core.identifier import ChannelId, Result
from qibolab._core.pulses.pulse import PulseId
from qibolab._core.sequence import PulseSequence
from qibolab._core.serialize import Model

__all__ = []

MeasureId = str


class Acquisition(Model):
num_bins: int
index: int


Acquisitions = dict[str, Acquisition]
Acquisitions = dict[MeasureId, Acquisition]


def acquisitions(sequence: PulseSequence, num_bins: int) -> Acquisitions:
return {
str(acq.id): Acquisition(num_bins=num_bins, index=i)
for i, acq in enumerate(
[p for _, p in sequence if isinstance(p, pulses.Acquisition)]
p for _, p in sequence if isinstance(p, pulses.Acquisition)
)
}

Expand Down Expand Up @@ -57,4 +61,8 @@ class IndexedData(TypedDict):
acquisition: Data


AcquiredData = dict[str, IndexedData]
AcquiredData = dict[MeasureId, IndexedData]


def extract(acquisitions: dict[ChannelId, AcquiredData]) -> dict[PulseId, Result]:
return {}
2 changes: 1 addition & 1 deletion src/qibolab/_core/instruments/qblox/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .program import program
from .waveforms import Waveform, Waveforms, waveform_indices, waveforms

__all__ = ["Sequence", "compile"]
__all__ = ["Sequence"]


Weight = Waveform
Expand Down
2 changes: 2 additions & 0 deletions src/qibolab/_core/instruments/qblox/sequence/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from qibolab._core.sequence import PulseSequence
from qibolab._core.serialize import ArrayList, Model

__all__ = []

ComponentId = tuple[str, int]
WaveformIndices = dict[ComponentId, int]

Expand Down

0 comments on commit d7eb614

Please sign in to comment.