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 Oct 19, 2023
1 parent 7e7bccb commit 9220a7c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* The function `enable_qccs_mode` of the HDAWG driver now accept an optional argument to select the QCCS generation.
It's advised to set it to 2 (gen2) when the HDAWG is operated with PQSC together with SHF instruments, and set it
to 1 (gen1) when the HDAWG is operated with PQSC together with UHFQA instruments.
* 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
11 changes: 7 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_css_files = ['zhinst-sphinx-theme/css/custom.css']
html_css_files = ["zhinst-sphinx-theme/css/custom.css"]

html_theme_options = {
"logo": {
Expand Down Expand Up @@ -111,7 +111,10 @@

# Spelling
# sphinxcontrib.spelling configuration file
spelling_word_list_filename='spelling_wordlist.txt'
spelling_word_list_filename = "spelling_wordlist.txt"
# Show suggestion in console output
spelling_show_suggestions=False
spelling_exclude_patterns=['examples/*.nblink', 'source/_static/zhinst-sphinx-theme/**/*']
spelling_show_suggestions = False
spelling_exclude_patterns = [
"examples/*.nblink",
"source/_static/zhinst-sphinx-theme/**/*",
]
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._waveforms = value
15 changes: 14 additions & 1 deletion tests/test_sequence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from zhinst.toolkit import Sequence, Waveforms
from zhinst.toolkit import Sequence, Waveforms, CommandTable


def test_assignment():
Expand Down Expand Up @@ -105,3 +105,16 @@ def test_to_string_existing_constant():
}
..."""
)


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


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

0 comments on commit 9220a7c

Please sign in to comment.