Skip to content

Commit

Permalink
Add test stub
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Sep 1, 2023
1 parent 5a1cadf commit 355b1f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
7 changes: 4 additions & 3 deletions qupulse/program/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import numpy as np

from qupulse._program.waveforms import Waveform
from qupulse import ChannelID
from qupulse.program.waveforms import Waveform
from qupulse.utils.types import MeasurementWindow, TimeType
from qupulse._program.volatile import VolatileRepetitionCount
from qupulse.program.volatile import VolatileRepetitionCount
from qupulse.parameter_scope import Scope

from typing import Protocol, runtime_checkable
Expand Down Expand Up @@ -78,7 +79,7 @@ def inner_scope(self, scope: Scope) -> Scope:
"""This function is necessary to inject program builder specific parameter implementations into the build
process."""

def hold_voltage(self, duration: HardwareTime, voltages: Mapping[str, HardwareVoltage]):
def hold_voltage(self, duration: HardwareTime, voltages: Mapping[ChannelID, HardwareVoltage]):
"""Supports dynamic i.e. for loop generated offsets and duration"""

# further specialized commandos like play_harmoic might be added here
Expand Down
16 changes: 13 additions & 3 deletions qupulse/program/decadac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Mapping, Optional, Sequence, ContextManager, Iterable
from typing import Mapping, Optional, Sequence, ContextManager, Iterable, Tuple

from qupulse import ChannelID, MeasurementWindow
from qupulse.parameter_scope import Scope
Expand All @@ -13,8 +13,18 @@ class DecaDACASCIIProgram:


class DecaDACASCIIBuilder:
def __init__(self):
pass
def __init__(self, channels: Tuple[Optional[ChannelID], ...]):
assert len(channels) in (20,), "Only 5 slots are supported for now"
self._name_to_idx = {idx: name for idx, name in enumerate(channels) if name is not None}
self._idx_to_name = channels

@classmethod
def from_channel_dict(cls, channels: Mapping[ChannelID, int]):
assert len(set(channels.values())) == len(channels), "no duplicate target channels"
channel_list = [None] * 20
for ch_name, ch_idx in channels.items():
channel_list[ch_idx] = ch_name
return cls(tuple(channel_list))

def inner_scope(self, scope: Scope) -> Scope:
"""This function is necessary to inject program builder specific parameter implementations into the build
Expand Down
Empty file added tests/program/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions tests/program/decadac_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest import TestCase

from qupulse.pulses import *
from qupulse.program.decadac import *


class DecaDacProgramBuilderTests(TestCase):
def test_single_channel_ramp(self):
hold = ConstantPT(10**6, {'a': '-1. + idx * 0.01'})
ramp = hold.with_iteration('idx', 200)

program_builder = DecaDACASCIIBuilder.from_channel_dict({'a': 0})
program = ramp.create_program(program_builder=program_builder)

raise NotImplementedError('the rest of the owl')

0 comments on commit 355b1f7

Please sign in to comment.