nsqdriver 0.10.0__cp312-cp312-macosx_10_13_universal2.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 nsqdriver might be problematic. Click here for more details.

nsqdriver/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ from .NS_MCI import Driver as MCIDriver
2
+ from .NS_QSYNC import Driver as QSYNCDriver
3
+ from .NS_CST import Driver as CSTDriver
4
+ from .compiler.ns_wave import InsChannel
5
+ from .compiler.py_wave_asm import nsw_config, AssemblyError
6
+
7
+ version_pack = (0, 10, 0)
8
+
9
+ __version__ = '.'.join(str(_) for _ in version_pack)
10
+ __all__ = ['MCIDriver', 'QSYNCDriver', 'CSTDriver', 'InsChannel']
nsqdriver/common.py ADDED
@@ -0,0 +1,20 @@
1
+ class Quantity(object):
2
+ def __init__(self, name: str, value=None, ch: int = 1, unit: str = ''):
3
+ self.name = name
4
+ self.default = dict(value=value, ch=ch, unit=unit)
5
+
6
+
7
+ class QInteger:
8
+ def __init__(self, name, value=None, unit='', ch=None,
9
+ get_cmd='', set_cmd='',):
10
+ self.name = name
11
+
12
+
13
+ class BaseDriver:
14
+ def __init__(self, addr, timeout, **kw):
15
+ self.addr = addr
16
+ self.timeout = timeout
17
+
18
+
19
+ def get_coef(*args):
20
+ return '', '', '', ''
File without changes
@@ -0,0 +1,151 @@
1
+ import numpy as np
2
+ import waveforms as wf
3
+
4
+ from enum import IntEnum
5
+ from typing import Union, List, Dict
6
+ from nsqdriver.compiler.py_wave_asm import *
7
+
8
+
9
+ class QInsPlaceholder(NSQCommand):
10
+ ...
11
+
12
+
13
+ class Wave(GenTagMixin):
14
+ class Tag(IntEnum): ...
15
+
16
+ def __init__(self, ins_obj: "InstructionQ", ins_id: dict): ...
17
+
18
+ class Frame(Wave):
19
+ def __init__(self, ins_obj: "InstructionQ", ins_id: int, freq: float): ...
20
+
21
+ @property
22
+ def freq(self) -> float: ...
23
+
24
+ @freq.setter
25
+ def freq(self, value: float): ...
26
+
27
+ def __mul__(self, other: Wave) -> Signal: ...
28
+
29
+ def format(self) -> "NSQCommand": ...
30
+
31
+
32
+ class Envelope(Wave):
33
+ def __init__(self, ins_obj: "InstructionQ", ins_id: int, content: "Union[wf.Waveform, np.ndarray]"): ...
34
+
35
+ @property
36
+ def content(self) -> "Union[wf.Waveform, np.ndarray]": ...
37
+
38
+ @content.setter
39
+ def content(self, value: "Union[wf.Waveform, np.ndarray]"): ...
40
+
41
+ def __mul__(self, other: Wave) -> Signal: ...
42
+
43
+ def format(self) -> "NSQCommand": ...
44
+
45
+
46
+ class Signal(Wave):
47
+ def __init__(self, ins_obj: "InstructionQ", ins_id: dict): ...
48
+
49
+
50
+ class InstructionQ(GenTagMixin):
51
+ """!
52
+ 包含各种具体的指令
53
+ """
54
+
55
+ def __init__(self, freqs=None, envelopes=None):
56
+ self.i_set: "List[Union[NSQCommand, InstructionQ]]" = []
57
+ self.f_set: "Dict[int, Frame]" = {}
58
+ self.e_set: "Dict[int, Envelope]" = {}
59
+ self.symbol_set: Dict[str, int] = {}
60
+ self.symbol_idx: int = -1
61
+ self.is_first_trig: bool = True
62
+ self.last_ins: NSQCommand
63
+
64
+ def clear(self) -> None: ...
65
+
66
+ @property
67
+ def length(self) -> int: ...
68
+
69
+ def ins_frame(self, freq, idx=None) -> Frame: ...
70
+
71
+ def ins_envelope(self, envelope: "Union[np.ndarray, wf.Waveform, str]", idx=None) -> Envelope: ...
72
+
73
+ def evlp_gaussian(self, width: float) -> Envelope: ...
74
+
75
+ def evlp_cospulse(self, width: float) -> Envelope: ...
76
+
77
+ def evlp_square(self, width: float) -> Envelope: ...
78
+
79
+ def _append_ins(self, cmd: "Union[NSQCommand, InstructionQ]"): ...
80
+
81
+ def _map_var(self, var: str) -> int: ...
82
+
83
+ def wait_for_trigger(self): ...
84
+
85
+ def ins_variable(self, reg: str, value: int): ...
86
+
87
+ def ins_add(self, reg: str, value: int): ...
88
+
89
+ def ins_reset_frame(self, flag: str, frame: "Frame"): ...
90
+
91
+ def inc_phase(self, frame: "Frame", phase: float): ...
92
+
93
+ def play_wave(self, wave: Signal, amp=1, freq=0, phase=0): ...
94
+
95
+ def play_zero(self, width: float): ...
96
+
97
+ def wait(self): ...
98
+
99
+ def end(self): ...
100
+
101
+ def capture(self, width: float, delay=0.): ...
102
+
103
+
104
+ class InsChannel(InstructionQ):
105
+ def __init__(self, freqs=None, envelopes=None):
106
+ self.if_stack: "List[InsIF]" = []
107
+ self.looping = False
108
+
109
+ def ins_if(self, formula: str) -> "InsIF": ...
110
+
111
+ def ins_else(self) -> "InsElse": ...
112
+
113
+ def ins_loop(self, times: int) -> "InsLoop": ...
114
+
115
+
116
+ class InsIF(InsChannel):
117
+ ch_judge_name = {f'FREQ_{i}': 1<<i for i in range(6)}
118
+
119
+ def __init__(self, freqs=None, envelopes=None):
120
+ self.channel: "InsChannel" = None
121
+ self.key_ins: "NSQCommand" = None
122
+ self.ins_else = None
123
+
124
+ @classmethod
125
+ def from_channel(cls, channel :InsChannel) -> InsIF: ...
126
+
127
+ @property
128
+ def formula(self): ...
129
+
130
+ @formula.setter
131
+ def formula(self, formula: str): ...
132
+
133
+
134
+ class InsElse(InsChannel):
135
+ def __init__(self, freqs=None, envelopes=None): ...
136
+
137
+ @classmethod
138
+ def from_channel(cls, channel: InsChannel) -> InsElse: ...
139
+
140
+ def capture(self, width: float, delay=0): ...
141
+
142
+
143
+ class InsLoop(InsChannel):
144
+ def __init__(self, freqs: float=None, envelopes: "Union[wf.Waveform, np.ndarray]"=None): ...
145
+
146
+ @classmethod
147
+ def from_channel(cls, channel: InsChannel) -> InsLoop: ...
148
+
149
+ def capture(self, width: float, delay=0): ...
150
+
151
+ def _compile(self) -> "List[NSQCommand]": ...
@@ -0,0 +1,29 @@
1
+ from typing import Any
2
+
3
+ import numpy as np
4
+
5
+
6
+ global_config = {
7
+ 'play_zero_step': 4e-9,
8
+ 'OUTSrate': 8e9,
9
+ 'envelope_dtype': np.int16, # 描述包络每个点的数据类型
10
+ 'envelope_step': 64, # 包络步进粒度,单位为bytes
11
+ 'envelope_quant': 16383, # 包络量化范围
12
+ 'envelope_cache': 204800, # 包络缓存大小,单位bytes
13
+ 'envelope_head': np.array([2, 0, 0, 4096, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=np.int16), # 包络更新包头
14
+ }
15
+
16
+
17
+ def nsw_config(name: str, value: Any) -> None: ...
18
+
19
+
20
+ class AssemblyError(RuntimeError): ...
21
+
22
+
23
+ class GenTagMixin: ...
24
+
25
+
26
+ class NSQCommand: ...
27
+
28
+
29
+ class Assembler: ...
@@ -0,0 +1,3 @@
1
+ from .kernel import *
2
+ from ._functions import *
3
+ from ._ir_pass import ir_pass as ir_pass
@@ -0,0 +1,96 @@
1
+ import numpy as np
2
+ from _typeshed import Incomplete
3
+
4
+ __all__ = ['AssemblyError', 'GenTagMixin', 'NSQCommand', 'QInsFrame', 'nsw_config', 'QInsEnvelope', 'QInsWait', 'QInsNop', 'QInsJumpImmediate', 'QInsPlayImm', 'QInsWaitTrig', 'QInsFrameRst', 'QInsWaitTrig', 'QInsFrameAdd', 'QInsCapture']
5
+
6
+ def nsw_config(name, value) -> None: ...
7
+
8
+ class QNumber:
9
+ value: int
10
+ def __init__(self) -> None: ...
11
+ def __int__(self) -> int: ...
12
+ def __float__(self) -> float: ...
13
+ def __bool__(self) -> bool: ...
14
+
15
+ class AssemblyError(RuntimeError): ...
16
+
17
+ class GenTagMixin:
18
+ @property
19
+ def generate_tag(self): ...
20
+
21
+ class NSQCommand(GenTagMixin):
22
+ tag: Incomplete
23
+ def __init__(self) -> None: ...
24
+ @property
25
+ def overhead(self): ...
26
+ @classmethod
27
+ def compile(cls, inst_list: list[Self]) -> tuple[np.ndarray, str]: ...
28
+
29
+ class QInsFrame(NSQCommand):
30
+ freq: Incomplete
31
+ phase: Incomplete
32
+ idx: Incomplete
33
+ def __init__(self, freq, phase, idx) -> None: ...
34
+ @property
35
+ def overhead(self): ...
36
+
37
+ class QInsEnvelope(NSQCommand):
38
+ envelope: Incomplete
39
+ envelop_slice: Incomplete
40
+ def __init__(self, envelope: np.ndarray) -> None: ...
41
+ def __len__(self) -> int: ...
42
+ def __bytes__(self) -> bytes: ...
43
+
44
+ class QInsFrameRst(NSQCommand):
45
+ @property
46
+ def overhead(self): ...
47
+
48
+ class QInsFrameAdd(NSQCommand):
49
+ frames: Incomplete
50
+ frequency: Incomplete
51
+ phase: Incomplete
52
+ def __init__(self, frames: list[QInsFrame], frequency: float, phase: float) -> None: ...
53
+ @property
54
+ def overhead(self): ...
55
+
56
+ class QInsWait(NSQCommand):
57
+ width: Incomplete
58
+ def __init__(self, width) -> None: ...
59
+ @property
60
+ def overhead(self): ...
61
+
62
+ class QInsWaitTrig(NSQCommand):
63
+ def __init__(self) -> None: ...
64
+ @property
65
+ def overhead(self): ...
66
+
67
+ class QInsNop(NSQCommand):
68
+ @property
69
+ def overhead(self): ...
70
+
71
+ class QInsJumpImmediate(NSQCommand):
72
+ idx: Incomplete
73
+ def __init__(self, idx: int) -> None: ...
74
+ @property
75
+ def overhead(self): ...
76
+
77
+ class QInsCapture(NSQCommand):
78
+ fre: Incomplete
79
+ acq_width: Incomplete
80
+ delay_width: Incomplete
81
+ play_width: Incomplete
82
+ para: Incomplete
83
+ def __init__(self, fre: list[int], acq_width: float, delay_width: float, play_width: float, raw_data_store: bool, iq_data_store: bool, judge_data_store: bool, double_fre_mode: bool) -> None: ...
84
+ @property
85
+ def overhead(self): ...
86
+
87
+ class QInsPlayImm(NSQCommand):
88
+ frame: Incomplete
89
+ freq: Incomplete
90
+ amp: Incomplete
91
+ bias: Incomplete
92
+ envelope: Incomplete
93
+ phase: Incomplete
94
+ def __init__(self, frame: QInsFrame, envelope: QInsEnvelope, amp, bias, freq, phase) -> None: ...
95
+ @property
96
+ def overhead(self): ...
@@ -0,0 +1,26 @@
1
+ import numpy as np
2
+ from ._asm import NSQCommand, QInsEnvelope, QInsFrame
3
+ from typing import Iterable, TypeVar
4
+
5
+ __all__ = ['Frame', 'Envelope', 'Int', 'Var', 'wait_for_trigger', 'ins_envelope', 'ins_frame', 'evlp_gaussian', 'evlp_square', 'evlp_cospulse', 'inc_phase', 'inc_frequency', 'reset_frame', 'play_wave', 'wait', 'capture']
6
+
7
+ Frame = TypeVar('Frame', bound=QInsFrame)
8
+ Envelope = TypeVar('Envelope', bound=QInsEnvelope)
9
+ Placeholder = TypeVar('Placeholder', bound=NSQCommand)
10
+ Var = TypeVar('Var')
11
+ Int = TypeVar('Int')
12
+ Uint = TypeVar('Uint')
13
+ Float = TypeVar('Float')
14
+
15
+ def ins_frame(freq: float, phase: float, *, idx: int = None) -> QInsFrame: ...
16
+ def ins_envelope(envelope: np.ndarray) -> QInsEnvelope: ...
17
+ def evlp_gaussian(width: float, srate: float = 8000000000.0) -> QInsEnvelope: ...
18
+ def evlp_cospulse(width: float, srate: float = 8000000000.0) -> QInsEnvelope: ...
19
+ def evlp_square(width: float, srate: float = 8000000000.0) -> QInsEnvelope: ...
20
+ def reset_frame(frame_list: Iterable[Frame] = ...) -> Placeholder: ...
21
+ def wait_for_trigger() -> Placeholder: ...
22
+ def inc_phase(frame_list: Iterable[Frame], phase: float) -> Placeholder: ...
23
+ def inc_frequency(frame_list: Iterable[Frame], freq: float) -> Placeholder: ...
24
+ def play_wave(envelope: QInsEnvelope, frame: QInsFrame, amp: int = 1, freq: int = 0, phase: int = 0) -> Placeholder: ...
25
+ def wait(width) -> Placeholder: ...
26
+ def capture(freq_list, acq_width: float, delay_width: float, play_width: float, raw_data_store: bool, iq_data_store: bool, judge_data_store: bool, double_fre_mode: bool) -> Int: ...
@@ -0,0 +1,45 @@
1
+ from ._functions import *
2
+ import ast
3
+ from _typeshed import Incomplete
4
+
5
+ __all__ = ['kernel', 'Kernel']
6
+
7
+ class KernelParseError(Exception): ...
8
+
9
+ class NSQCKernel(type):
10
+ def __init__(cls, name, bases, attrs) -> None: ...
11
+
12
+ class Kernel(ast.NodeVisitor, metaclass=NSQCKernel):
13
+ max_frame: int
14
+ name: Incomplete
15
+ func_args: Incomplete
16
+ func_kwargs: Incomplete
17
+ top_src: Incomplete
18
+ top_node: Incomplete
19
+ var_symbol: Incomplete
20
+ frame_symbol: Incomplete
21
+ frame_idx: int
22
+ envelope_symbol: Incomplete
23
+ register_symbol: Incomplete
24
+ register_idx: int
25
+ instruction_list: Incomplete
26
+ def __init__(self, func: Incomplete | None = None, args: Incomplete | None = None, kwargs: Incomplete | None = None) -> None: ...
27
+ def clear(self) -> None: ...
28
+ def parse(self): ...
29
+ def show(self) -> None: ...
30
+ def __call__(self, *args, **kwargs): ...
31
+ def visit_arg(self, node: ast.arg): ...
32
+ def visit_Assign(self, node: ast.Assign): ...
33
+ def visit_AugAssign(self, node: ast.AugAssign): ...
34
+ def visit_AnnAssign(self, node: ast.AnnAssign): ...
35
+ def visit_Call(self, node: ast.Call) -> object: ...
36
+ def visit_BinOp(self, node: ast.BinOp): ...
37
+ def visit_Constant(self, node): ...
38
+ def visit_Expr(self, node: ast.Expr): ...
39
+ def visit_If(self, node: ast.If): ...
40
+ def visit_Return(self, node) -> None: ...
41
+ def visit_FunctionDef(self, node: ast.FunctionDef): ...
42
+ def visit_arguments(self, node: ast.arguments): ...
43
+ def visit_Module(self, node: ast.Module): ...
44
+
45
+ def kernel(func): ...