ionpulse_sequence_generator 2.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ionpulse_sequence_generator might be problematic. Click here for more details.
- ionpulse_sequence_generator/__init__.py +91 -0
- ionpulse_sequence_generator/base/__init__.py +0 -0
- ionpulse_sequence_generator/base/configuration.py +23 -0
- ionpulse_sequence_generator/base/header.py +90 -0
- ionpulse_sequence_generator/base/jsonexportable.py +264 -0
- ionpulse_sequence_generator/event/__init__.py +0 -0
- ionpulse_sequence_generator/event/ddspidstatechange.py +65 -0
- ionpulse_sequence_generator/event/dioevent.py +73 -0
- ionpulse_sequence_generator/event/event.py +84 -0
- ionpulse_sequence_generator/event/multitonerfevent.py +139 -0
- ionpulse_sequence_generator/event/qubitevent.py +66 -0
- ionpulse_sequence_generator/event/readout.py +239 -0
- ionpulse_sequence_generator/event/singletonerfevent.py +185 -0
- ionpulse_sequence_generator/event/wait.py +63 -0
- ionpulse_sequence_generator/event/waveform.py +54 -0
- ionpulse_sequence_generator/hardware/__init__.py +0 -0
- ionpulse_sequence_generator/hardware/channel.py +115 -0
- ionpulse_sequence_generator/hardware/device.py +184 -0
- ionpulse_sequence_generator/hardware/hardware.py +780 -0
- ionpulse_sequence_generator/hardware/readout.py +500 -0
- ionpulse_sequence_generator/hardware/system.py +213 -0
- ionpulse_sequence_generator/hardware/units.py +97 -0
- ionpulse_sequence_generator/parameter/__init__.py +0 -0
- ionpulse_sequence_generator/parameter/parameter.py +479 -0
- ionpulse_sequence_generator/parameter/pid_parameter.py +118 -0
- ionpulse_sequence_generator/parameter/spline_parameter.py +370 -0
- ionpulse_sequence_generator/py.typed +0 -0
- ionpulse_sequence_generator/sequence/__init__.py +0 -0
- ionpulse_sequence_generator/sequence/conditional.py +121 -0
- ionpulse_sequence_generator/sequence/loop.py +108 -0
- ionpulse_sequence_generator/sequence/sequence.py +882 -0
- ionpulse_sequence_generator/utils/__init__.py +0 -0
- ionpulse_sequence_generator/utils/logging.py +96 -0
- ionpulse_sequence_generator/utils/utils.py +38 -0
- ionpulse_sequence_generator-2.4.1.dist-info/METADATA +52 -0
- ionpulse_sequence_generator-2.4.1.dist-info/RECORD +37 -0
- ionpulse_sequence_generator-2.4.1.dist-info/WHEEL +4 -0
|
File without changes
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import logging.config
|
|
3
|
+
import sys
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from copy import copy
|
|
6
|
+
from typing import ClassVar, Literal
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
DEFAULT_LOG_LEVEL = logging.DEBUG
|
|
13
|
+
|
|
14
|
+
LOGGING_CONFIG = {
|
|
15
|
+
"version": 1,
|
|
16
|
+
"disable_existing_loggers": False,
|
|
17
|
+
"formatters": {
|
|
18
|
+
"default": {
|
|
19
|
+
"()": "ionpulse_sequence_generator.utils.logging.DefaultFormatter",
|
|
20
|
+
"fmt": "%(asctime)s.%(msecs)03d | %(levelprefix)s | %(name)s:%(funcName)s:%(lineno)d - %(message)s",
|
|
21
|
+
"datefmt": "%Y-%m-%d %H:%M:%S",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
"handlers": {
|
|
25
|
+
"default": {
|
|
26
|
+
"formatter": "default",
|
|
27
|
+
"class": "logging.StreamHandler",
|
|
28
|
+
"stream": "ext://sys.stderr", # this needs to stay on stderr (used to see generation errors in icon)
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
"loggers": {
|
|
32
|
+
"ionpulse_sequence_generator": {"handlers": ["default"], "level": DEFAULT_LOG_LEVEL, "propagate": False},
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DefaultFormatter(logging.Formatter):
|
|
38
|
+
"""
|
|
39
|
+
# DefaultFormatter
|
|
40
|
+
A custom log formatter class that:
|
|
41
|
+
|
|
42
|
+
- Outputs the LOG_LEVEL with an appropriate color.
|
|
43
|
+
- If a log call includes an `extras={"color_message": ...}` it will be used
|
|
44
|
+
for formatting the output, instead of the plain text message.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
level_name_colors: ClassVar[dict[int, Callable[..., str]]] = {
|
|
48
|
+
logging.DEBUG: lambda level_name: click.style(str(level_name), fg="cyan"),
|
|
49
|
+
logging.INFO: lambda level_name: click.style(str(level_name), fg="green"),
|
|
50
|
+
logging.WARNING: lambda level_name: click.style(str(level_name), fg="yellow"),
|
|
51
|
+
logging.ERROR: lambda level_name: click.style(str(level_name), fg="red"),
|
|
52
|
+
logging.CRITICAL: lambda level_name: click.style(str(level_name), fg="bright_red"),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
fmt: str | None = None,
|
|
58
|
+
datefmt: str | None = None,
|
|
59
|
+
style: Literal["%", "{", "$"] = "%",
|
|
60
|
+
use_colors: bool | None = None,
|
|
61
|
+
) -> None:
|
|
62
|
+
if use_colors in (True, False):
|
|
63
|
+
self.use_colors = use_colors
|
|
64
|
+
else:
|
|
65
|
+
self.use_colors = sys.stdout.isatty()
|
|
66
|
+
super().__init__(fmt=fmt, datefmt=datefmt, style=style)
|
|
67
|
+
|
|
68
|
+
def color_level_name(self, level_name: str, level_no: int) -> str:
|
|
69
|
+
def default(level_name: str) -> str:
|
|
70
|
+
return str(level_name)
|
|
71
|
+
|
|
72
|
+
func = self.level_name_colors.get(level_no, default)
|
|
73
|
+
return func(level_name)
|
|
74
|
+
|
|
75
|
+
def formatMessage(self, record: logging.LogRecord) -> str: # noqa: N802
|
|
76
|
+
recordcopy = copy(record)
|
|
77
|
+
levelname = recordcopy.levelname
|
|
78
|
+
seperator = " " * (8 - len(recordcopy.levelname))
|
|
79
|
+
if self.use_colors:
|
|
80
|
+
levelname = self.color_level_name(levelname, recordcopy.levelno)
|
|
81
|
+
if "color_message" in recordcopy.__dict__:
|
|
82
|
+
recordcopy.msg = recordcopy.__dict__["color_message"]
|
|
83
|
+
recordcopy.__dict__["message"] = recordcopy.getMessage()
|
|
84
|
+
recordcopy.__dict__["levelprefix"] = levelname + seperator
|
|
85
|
+
return logging.Formatter.formatMessage(self, recordcopy)
|
|
86
|
+
|
|
87
|
+
def should_use_colors(self) -> bool:
|
|
88
|
+
return sys.stderr.isatty()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def setup_logging() -> None:
|
|
92
|
+
"""Configures the logging settings for the application."""
|
|
93
|
+
|
|
94
|
+
logger.debug("Configuring pydase logging.")
|
|
95
|
+
|
|
96
|
+
logging.config.dictConfig(LOGGING_CONFIG)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def error_if_false(cond: bool, msg: str) -> None:
|
|
9
|
+
"""Logs an error message if the condition is not met"""
|
|
10
|
+
if not cond:
|
|
11
|
+
logger.error(msg)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# check used channels if they match with defined channels
|
|
15
|
+
def is_not_sparse(s: set) -> bool:
|
|
16
|
+
"""Checks if a set of numbers is sparse"""
|
|
17
|
+
if len(s) == 0:
|
|
18
|
+
return True
|
|
19
|
+
if len(s) == 1: # only one element
|
|
20
|
+
return list(s)[0] == 0 # noqa: RUF015
|
|
21
|
+
arr = np.sort(np.array(list(s)))
|
|
22
|
+
arr = arr[arr >= 0]
|
|
23
|
+
return (arr[1:] - arr[0:-1] == 1).all() and arr[0] == 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def singleton(class_):
|
|
27
|
+
"""
|
|
28
|
+
Singleton decorator, marks a class as singleton.
|
|
29
|
+
https://stackoverflow.com/questions/6760685/what-is-the-best-way-of-implementing-singleton-in-python
|
|
30
|
+
"""
|
|
31
|
+
_instances = {}
|
|
32
|
+
|
|
33
|
+
def getinstance(*args, **kwargs):
|
|
34
|
+
if class_ not in _instances:
|
|
35
|
+
_instances[class_] = class_(*args, **kwargs)
|
|
36
|
+
return _instances[class_]
|
|
37
|
+
|
|
38
|
+
return getinstance
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ionpulse_sequence_generator
|
|
3
|
+
Version: 2.4.1
|
|
4
|
+
Author-email: Martin Stadler <mstadle@phys.ethz.ch>, Alexander Ferk <alferk@phys.ethz.ch>, Mose Mueller <mosmuell@ethz.ch>, Carmelo Mordini <carmelo@zuriq.com>
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: <4,>=3.10
|
|
7
|
+
Requires-Dist: click<9,>=8.2.1
|
|
8
|
+
Requires-Dist: msgpack<2,>=1.0.5
|
|
9
|
+
Requires-Dist: numpy<3,>=2.2
|
|
10
|
+
Requires-Dist: orjson<4,>=3.10
|
|
11
|
+
Requires-Dist: scipy<2,>=1.15
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Ionpulse Sequence Generator
|
|
15
|
+
This package provides a convenient API to create pulse sequences for the ionpulse application running on M-ACTION or QUENCH. It generates a dictionary which can be translated into JSON and sent to ionpulse as a string, generating a sequence of operations.
|
|
16
|
+
|
|
17
|
+
The sequence generator is meant to be used as a dependency of [pycrystal](https://gitlab.phys.ethz.ch/tiqi-projects/pycrystal), but can be used standalone.
|
|
18
|
+
|
|
19
|
+
To connect to to Ionpulse, you can use e.g. [tiqi-zedboard](https://gitlab.phys.ethz.ch/tiqi-projects/drivers/tiqi-zedboard) for this.
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
Contributions to the sequence generator are always welcome!
|
|
23
|
+
|
|
24
|
+
To contribute, please create a virtual environment to run the tests and formatting from:
|
|
25
|
+
```
|
|
26
|
+
uv sync
|
|
27
|
+
```
|
|
28
|
+
Then install the pre-commit hook for formatting your code using Ruff:
|
|
29
|
+
```
|
|
30
|
+
uv run pre-commit install
|
|
31
|
+
```
|
|
32
|
+
For VSCode you can also install the Ruff formatting extension.
|
|
33
|
+
|
|
34
|
+
As this package integrates with [pycrystal](https://gitlab.phys.ethz.ch/tiqi-projects/pycrystal), [ionpulse](https://gitlab.phys.ethz.ch/tiqi-projects/ionpulse_sdk_core) and the [ionpulse-sequence-visualizer](https://gitlab.phys.ethz.ch/tiqi-projects/library-visualiser), integration testing with these projects is important before contributions can be merged.
|
|
35
|
+
|
|
36
|
+
Integration tests with [ionpulse-sequence-visualizer](https://gitlab.phys.ethz.ch/tiqi-projects/library-visualiser) are currently performed automatically with a cross project pipeline.
|
|
37
|
+
|
|
38
|
+
For [pycrystal](https://gitlab.phys.ethz.ch/tiqi-projects/pycrystal) and [ionpulse](https://gitlab.phys.ethz.ch/tiqi-projects/ionpulse_sdk_core) integration tests have to be performed manually.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
For standalone use we recommend installing with `poetry`:
|
|
43
|
+
```sh
|
|
44
|
+
uv add ionpulse_sequence_generator @ git+ssh://git@gitlab.phys.ethz.ch:tiqi-projects/ionpulse_sequence_generator
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For installation with `pip` use
|
|
48
|
+
```sh
|
|
49
|
+
pip install [-e] git+ssh://git@gitlab.phys.ethz.ch:tiqi-projects/ionpulse_sequence_generator
|
|
50
|
+
```
|
|
51
|
+
with the `-e` flag to install in editable mode.
|
|
52
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
ionpulse_sequence_generator/__init__.py,sha256=mj1EVG3e3MEvsS4m2zj4cAF3znrjxNdEWLTNHNNOBZw,2262
|
|
2
|
+
ionpulse_sequence_generator/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
ionpulse_sequence_generator/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
ionpulse_sequence_generator/base/configuration.py,sha256=Bw5mSOlSeOlhdP3JWub3o2rsZV1qXNyc2Gkboikim7U,905
|
|
5
|
+
ionpulse_sequence_generator/base/header.py,sha256=2IOVDk3V2TqEHg4wbtqgPnM3e5_jvaOydS8-9Q4XxN4,3174
|
|
6
|
+
ionpulse_sequence_generator/base/jsonexportable.py,sha256=rg-IW-fVAFEem25zNFDXJjvOcypDBiNVXFSRBFdfi4I,10630
|
|
7
|
+
ionpulse_sequence_generator/event/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
ionpulse_sequence_generator/event/ddspidstatechange.py,sha256=a2z2rq412rhNyNXWq-LmbMB5Ql0C26ka9he7-dCLQbk,1946
|
|
9
|
+
ionpulse_sequence_generator/event/dioevent.py,sha256=xKVUDGkFclJ6ytwgNen7qBSJVKVQPGL2q9MxxYSz6sk,2466
|
|
10
|
+
ionpulse_sequence_generator/event/event.py,sha256=PQVxUpk-RYIq51ZEuZb1GWq28VnSPoIJP9ZrHHYDi5k,2730
|
|
11
|
+
ionpulse_sequence_generator/event/multitonerfevent.py,sha256=t_gnA2UZ9pzBV7-jgSw4Op9k_CKAjA9pKHbi-wjEbNQ,5280
|
|
12
|
+
ionpulse_sequence_generator/event/qubitevent.py,sha256=cgSIqd7R9okcdFkTPYmjBeWbyqoNWdtkDmmWMLwLCk0,1748
|
|
13
|
+
ionpulse_sequence_generator/event/readout.py,sha256=s2O_UzkvPZnIKfpTfVMmiePW9Tk2ea4burBzVmIfWQg,7885
|
|
14
|
+
ionpulse_sequence_generator/event/singletonerfevent.py,sha256=LDcP7n2MNZ8yQvqwuOdCLM6OpD8OHIbCqWGKDWvdFuE,6363
|
|
15
|
+
ionpulse_sequence_generator/event/wait.py,sha256=eMe9NObkyoOulnwcFAfUuO-jhVqT7GUetqrXDmudPBc,1840
|
|
16
|
+
ionpulse_sequence_generator/event/waveform.py,sha256=jDKwZA2Dg7oZMWv2u3D-qNYp0-haIcFqujj2SlWN7nk,1608
|
|
17
|
+
ionpulse_sequence_generator/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
ionpulse_sequence_generator/hardware/channel.py,sha256=nxA-LZp4Qb9t5CWlJYRDDWXG3KVwmJt2g1uv-lNNaEA,3486
|
|
19
|
+
ionpulse_sequence_generator/hardware/device.py,sha256=AubNXjxnC-U8p7VkPoZd0ALiP4Jro4zgK3xc6llI0Jk,5557
|
|
20
|
+
ionpulse_sequence_generator/hardware/hardware.py,sha256=UqK-v0P5Z9rKivGcU3ne3U1P4HMFEQYgR3U8cLGhlnc,31042
|
|
21
|
+
ionpulse_sequence_generator/hardware/readout.py,sha256=2x36AVaCCOvVjUgw5ZsA2hHZDF2NFaWw8Qx-cj18XGs,21455
|
|
22
|
+
ionpulse_sequence_generator/hardware/system.py,sha256=wYIeTmB7yHTcon6GLScSer1HTHf9ksgchGyzvwl4r_c,7651
|
|
23
|
+
ionpulse_sequence_generator/hardware/units.py,sha256=5uOlgQW4IbaXYHiiH8XwkY8jHrHShk8ijA-NC4Colqs,3688
|
|
24
|
+
ionpulse_sequence_generator/parameter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
ionpulse_sequence_generator/parameter/parameter.py,sha256=JlhGPKksSSMN_covEki6bgcXKX-QadHUANFsk7H47XU,15951
|
|
26
|
+
ionpulse_sequence_generator/parameter/pid_parameter.py,sha256=Y7xFyXT1aVUCjnVfjbNdJF2rVw5wnn80q7Yn-Bfp1KE,4067
|
|
27
|
+
ionpulse_sequence_generator/parameter/spline_parameter.py,sha256=sEIFFzO5Fg5GsyOJuzvuuCvfE-cLsHISwiOEhJCi2Q0,16577
|
|
28
|
+
ionpulse_sequence_generator/sequence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
+
ionpulse_sequence_generator/sequence/conditional.py,sha256=3ItpoV7aqEHA2y0Qmmsf2E6hojABedDFUPKW6uT0qEw,4897
|
|
30
|
+
ionpulse_sequence_generator/sequence/loop.py,sha256=eINF8gaEGxCcJh-La4hICVyCZXvCRZTtJnAxOqmmJxg,3527
|
|
31
|
+
ionpulse_sequence_generator/sequence/sequence.py,sha256=2LKLJS0UV5Nik078hG7sTLDJULXELEusWDUnXTim0kI,37363
|
|
32
|
+
ionpulse_sequence_generator/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
+
ionpulse_sequence_generator/utils/logging.py,sha256=TVL4_9psXSeA-7YG7EJ0uYrSECxrSBCAyrrwp7-dY-4,3394
|
|
34
|
+
ionpulse_sequence_generator/utils/utils.py,sha256=9_nt3wVwGYiv2KQ_wMF3BJabTCiIaS_S0ptNTn9Wm70,1028
|
|
35
|
+
ionpulse_sequence_generator-2.4.1.dist-info/METADATA,sha256=-dGQxEFrviAJciye1fFxDsWZIeMlilo66sLqWNfNwm0,2541
|
|
36
|
+
ionpulse_sequence_generator-2.4.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
37
|
+
ionpulse_sequence_generator-2.4.1.dist-info/RECORD,,
|