Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nulinspiratie committed Nov 20, 2024
1 parent 62bb36f commit 034b2f7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions quam/components/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def apply_to_config(self, config: dict) -> None:
}


@quam_dataclass
class TimeTaggingAddon(QuamComponent):
"""Addon to perform time tagging on a channel.
Expand Down
49 changes: 49 additions & 0 deletions tests/components/channels/test_time_tagging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from quam.components.channels import SingleChannel, TimeTaggingAddon
from quam.core.quam_classes import QuamRoot, quam_dataclass


@quam_dataclass
class SingleChannelQuAM(QuamRoot):
channel: SingleChannel


def test_time_tagging_cfg():
channel = SingleChannel(id="channel", opx_output=("con1", 1))
channel.time_tagging = TimeTaggingAddon()

machine = SingleChannelQuAM(channel=channel)
cfg = machine.generate_config()

assert "outputPulseParameters" in cfg["elements"]["channel"]
assert cfg["elements"]["channel"]["outputPulseParameters"] == {
"signalThreshold": 800,
"signalPolarity": "below",
"derivativeThreshold": 300,
"derivativePolarity": "below",
}


def test_time_tagging_cfg_disabled():
channel = SingleChannel(id="channel", opx_output=("con1", 1))
channel.time_tagging = TimeTaggingAddon(enabled=False)

machine = SingleChannelQuAM(channel=channel)
cfg = machine.generate_config()
assert "outputPulseParameters" not in cfg["elements"]["channel"]


def test_time_tagging_cfg_custom_thresholds():
channel = SingleChannel(id="channel", opx_output=("con1", 1))
channel.time_tagging = TimeTaggingAddon(
signal_threshold=0.2, derivative_threshold=0.1
)

machine = SingleChannelQuAM(channel=channel)
cfg = machine.generate_config()
assert "outputPulseParameters" in cfg["elements"]["channel"]
assert cfg["elements"]["channel"]["outputPulseParameters"] == {
"signalThreshold": int(0.2 * 4096),
"signalPolarity": "below",
"derivativeThreshold": int(0.1 * 4096),
"derivativePolarity": "below",
}

0 comments on commit 034b2f7

Please sign in to comment.