Skip to content

Commit

Permalink
Add a comman table property to the sequencer class
Browse files Browse the repository at this point in the history
Often a command table is associated with a specific sequencer
code. This commit simplt adds a property as a "storage" in the
sequencer class for a command table. There is no logic attached
to this other then storing.
  • Loading branch information
tobiasah committed Nov 2, 2023
1 parent e082c54 commit 3a39c4f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Improved `CommandTable` performance when `CommandTable.active_validation` is disabled.
* Added `CommandTable.is_valid()` method to check validity of the command table.
* Added `py.typed` type information marker file.
* Add command table property to the sequencer class to have a simple way to store them together.

## Version 0.6.1
* Deep gets on nodes with keywords returns an enum like the regular get.
Expand Down
25 changes: 19 additions & 6 deletions src/zhinst/toolkit/sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Custom sequence code class."""
from zhinst.toolkit.waveform import Waveforms
from zhinst.toolkit.command_table import CommandTable
import re
import typing as t

Expand Down Expand Up @@ -57,10 +58,12 @@ def __init__(
*,
constants: t.Dict[str, float] = None,
waveforms: Waveforms = None,
command_table: CommandTable = None,
):
self._partial_seq = code if code else ""
self._constants = constants if constants else {}
self._waveforms = waveforms
self._command_table = command_table

def __str__(self) -> str:
return self.to_string()
Expand Down Expand Up @@ -102,31 +105,41 @@ def to_string(self, *, waveform_snippet: bool = True) -> str:
return sequence

@property
def code(self):
def code(self) -> str:
"""Code of the Sequence."""
return self._partial_seq

@code.setter
def code(self, value):
def code(self, value: str) -> None:
"""Code of the Sequence."""
self._partial_seq = value

@property
def constants(self):
def constants(self) -> t.Dict[str, float]:
"""Constants of the Sequence."""
return self._constants

@constants.setter
def constants(self, value):
def constants(self, value: t.Dict[str, float]) -> None:
"""Constants of the Sequence."""
self._constants = value

@property
def waveforms(self):
def waveforms(self) -> Waveforms:
"""Waveforms of the Sequence."""
return self._waveforms

@waveforms.setter
def waveforms(self, value):
def waveforms(self, value: Waveforms) -> None:
"""Waveforms of the Sequence."""
self._waveforms = value

@property
def command_table(self) -> CommandTable:
"""Command table of the Sequence."""
return self._command_table

@command_table.setter
def command_table(self, value: CommandTable) -> None:
"""Command table of the Sequence."""
self._command_table = value
14 changes: 14 additions & 0 deletions tests/command_table/test_sequence_ct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from zhinst.toolkit import Sequence, CommandTable


def test_setting_command_table(command_table_schema):
sequencer = Sequence()
ct = CommandTable(command_table_schema)
sequencer.command_table = ct
assert sequencer.command_table == ct


def test_setting_command_table_constructor(command_table_schema):
ct = CommandTable(command_table_schema)
sequencer = Sequence(command_table=ct)
assert sequencer.command_table == ct

0 comments on commit 3a39c4f

Please sign in to comment.