QuLab 2.10.6__cp312-cp312-macosx_10_13_universal2.whl → 2.10.8__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.
- qulab/expression.py +36 -8
- qulab/fun.cpython-312-darwin.so +0 -0
- qulab/scan/query.py +13 -0
- qulab/scan/scan.py +0 -1
- qulab/scan/server.py +11 -9
- qulab/scan/utils.py +7 -2
- qulab/sys/rpc/zmq_socket.py +9 -2
- qulab/version.py +1 -1
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/METADATA +1 -1
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/RECORD +14 -14
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/WHEEL +1 -1
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/entry_points.txt +0 -0
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/licenses/LICENSE +0 -0
- {qulab-2.10.6.dist-info → qulab-2.10.8.dist-info}/top_level.txt +0 -0
qulab/expression.py
CHANGED
@@ -4,10 +4,11 @@ import operator
|
|
4
4
|
|
5
5
|
import numpy as np
|
6
6
|
from pyparsing import (CaselessKeyword, Combine, Forward, Group, Keyword,
|
7
|
-
Literal, Optional, ParserElement,
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Literal, MatchFirst, Optional, ParserElement,
|
8
|
+
ParseResults, Regex, Suppress, Word, ZeroOrMore,
|
9
|
+
alphanums, alphas, delimitedList, infixNotation, nums,
|
10
|
+
oneOf, opAssoc, pyparsing_common, restOfLine, srange,
|
11
|
+
stringEnd, stringStart)
|
11
12
|
from scipy import special
|
12
13
|
|
13
14
|
# 启用 Packrat 优化以提高解析效率
|
@@ -37,7 +38,23 @@ def symbol_parse_action(t):
|
|
37
38
|
return Symbol(t[0])
|
38
39
|
|
39
40
|
|
40
|
-
SYMBOL = Word(alphas
|
41
|
+
SYMBOL = Word(alphas + "_",
|
42
|
+
alphanums + "_").setParseAction(symbol_parse_action)
|
43
|
+
|
44
|
+
|
45
|
+
# 定义查询语法:$a.b.c 或 $a.b 或 $a
|
46
|
+
def query_parse_action(t):
|
47
|
+
return Query(t[0])
|
48
|
+
|
49
|
+
|
50
|
+
attr_chain = ZeroOrMore(Combine(Literal('.') + SYMBOL))
|
51
|
+
dollar_named_chain = Combine(Literal('$') + SYMBOL + attr_chain)
|
52
|
+
dollar_dotN_chain = Combine(
|
53
|
+
Literal('$') + Regex(r'\.{1,}') + SYMBOL + attr_chain)
|
54
|
+
dollar_simple = Combine(Literal('$') + SYMBOL)
|
55
|
+
|
56
|
+
QUERY = MatchFirst([dollar_dotN_chain, dollar_named_chain,
|
57
|
+
dollar_simple]).setParseAction(lambda s, l, t: Query(t[0]))
|
41
58
|
|
42
59
|
#------------------------------------------------------------------------------
|
43
60
|
# 定义运算表达式的解析动作转换函数
|
@@ -97,7 +114,7 @@ expr = Forward()
|
|
97
114
|
#------------------------------------------------------------------------------
|
98
115
|
# 构造基元表达式:包括数值、标识符、括号内表达式
|
99
116
|
atom = (
|
100
|
-
FLOAT | INT | OCT | HEX | SYMBOL |
|
117
|
+
FLOAT | INT | OCT | HEX | SYMBOL | QUERY |
|
101
118
|
(LPAREN + expr + RPAREN) # 注意:后面我们将使用递归定义 expr
|
102
119
|
)
|
103
120
|
|
@@ -173,6 +190,7 @@ class Env():
|
|
173
190
|
self.consts = {}
|
174
191
|
self.variables = {}
|
175
192
|
self.refs = {}
|
193
|
+
self.nested = {}
|
176
194
|
self.functions = {
|
177
195
|
'sin': np.sin,
|
178
196
|
'cos': np.cos,
|
@@ -745,6 +763,15 @@ class Symbol(Expression):
|
|
745
763
|
return self.name
|
746
764
|
|
747
765
|
|
766
|
+
class Query(Symbol):
|
767
|
+
|
768
|
+
def derivative(self, x):
|
769
|
+
return 0
|
770
|
+
|
771
|
+
def eval(self, env):
|
772
|
+
return super().eval(env)
|
773
|
+
|
774
|
+
|
748
775
|
sin = Symbol('sin')
|
749
776
|
cos = Symbol('cos')
|
750
777
|
tan = Symbol('tan')
|
@@ -773,7 +800,7 @@ erf = Symbol('erf')
|
|
773
800
|
erfc = Symbol('erfc')
|
774
801
|
|
775
802
|
|
776
|
-
def calc(exp: str | Expression, **kwargs) -> Expression:
|
803
|
+
def calc(exp: str | Expression, env: Env = None, **kwargs) -> Expression:
|
777
804
|
"""
|
778
805
|
Calculate the expression.
|
779
806
|
|
@@ -791,7 +818,8 @@ def calc(exp: str | Expression, **kwargs) -> Expression:
|
|
791
818
|
Expression
|
792
819
|
The calculated expression.
|
793
820
|
"""
|
794
|
-
env
|
821
|
+
if env is None:
|
822
|
+
env = Env()
|
795
823
|
for k, v in kwargs.items():
|
796
824
|
env[k] = v
|
797
825
|
if isinstance(exp, str):
|
qulab/fun.cpython-312-darwin.so
CHANGED
Binary file
|
qulab/scan/query.py
CHANGED
@@ -372,3 +372,16 @@ def lookup_list(*, full=False):
|
|
372
372
|
return __query_state.table['body']
|
373
373
|
else:
|
374
374
|
return [r[0] for r in __query_state.table['body']]
|
375
|
+
|
376
|
+
|
377
|
+
def ping(database=default_server, timeout=1, socket=None):
|
378
|
+
with ZMQContextManager(zmq.DEALER,
|
379
|
+
connect=database,
|
380
|
+
socket=socket,
|
381
|
+
timeout=timeout) as socket:
|
382
|
+
|
383
|
+
socket.send_pyobj({'method': 'ping'})
|
384
|
+
try:
|
385
|
+
return socket.recv_pyobj()
|
386
|
+
except zmq.Again:
|
387
|
+
raise TimeoutError(f"No response from server within {timeout} s")
|
qulab/scan/scan.py
CHANGED
qulab/scan/server.py
CHANGED
@@ -23,15 +23,16 @@ from .models import Session, create_engine, create_tables, sessionmaker, utcnow
|
|
23
23
|
from .record import BufferList, Record, random_path
|
24
24
|
from .utils import dump_dict, load_dict
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
default_record_port = get_config_value('port',
|
27
|
+
int,
|
28
|
+
command_name='server',
|
29
|
+
default=6789)
|
30
|
+
|
31
|
+
datapath = get_config_value('data',
|
32
|
+
Path,
|
33
|
+
command_name='server',
|
34
|
+
default=Path.home() / 'qulab' / 'data')
|
35
|
+
|
35
36
|
datapath.mkdir(parents=True, exist_ok=True)
|
36
37
|
|
37
38
|
namespace = uuid.uuid4()
|
@@ -376,6 +377,7 @@ async def serv(port,
|
|
376
377
|
url='',
|
377
378
|
buffer_size=1024 * 1024 * 1024,
|
378
379
|
interval=60):
|
380
|
+
datapath.mkdir(parents=True, exist_ok=True)
|
379
381
|
logger.debug('Creating socket...')
|
380
382
|
async with ZMQContextManager(zmq.ROUTER, bind=f"tcp://*:{port}") as sock:
|
381
383
|
logger.info(f'Server started at port {port}.')
|
qulab/scan/utils.py
CHANGED
@@ -198,8 +198,13 @@ def yapf_reformat(cell_text):
|
|
198
198
|
return '\n'.join(lines)
|
199
199
|
|
200
200
|
cell_text = re.sub('^%', '#%#', cell_text, flags=re.M)
|
201
|
-
|
202
|
-
yapf.yapflib.yapf_api.FormatCode(
|
201
|
+
try:
|
202
|
+
reformated_text = yapf.yapflib.yapf_api.FormatCode(
|
203
|
+
isort.code(cell_text))[0]
|
204
|
+
except:
|
205
|
+
reformated_text = unwrap(
|
206
|
+
yapf.yapflib.yapf_api.FormatCode(wrap(
|
207
|
+
isort.code(cell_text)))[0])
|
203
208
|
return re.sub('^#%#', '%', reformated_text, flags=re.M)
|
204
209
|
except:
|
205
210
|
return cell_text
|
qulab/sys/rpc/zmq_socket.py
CHANGED
@@ -99,7 +99,8 @@ class ZMQContextManager:
|
|
99
99
|
secret_key: Optional[bytes] = None,
|
100
100
|
public_key: Optional[bytes] = None,
|
101
101
|
server_public_key: Optional[bytes] = None,
|
102
|
-
socket: Optional[zmq.Socket] = None
|
102
|
+
socket: Optional[zmq.Socket] = None,
|
103
|
+
timeout: Optional[float] = None):
|
103
104
|
self.socket_type = socket_type
|
104
105
|
if bind is None and connect is None:
|
105
106
|
raise ValueError("Either 'bind' or 'connect' must be specified.")
|
@@ -110,6 +111,7 @@ class ZMQContextManager:
|
|
110
111
|
self.secret_key = secret_key
|
111
112
|
self.public_key = public_key
|
112
113
|
self.server_public_key = server_public_key
|
114
|
+
self.timeout = timeout
|
113
115
|
|
114
116
|
if secret_key_file:
|
115
117
|
self.public_key, self.secret_key = zmq.auth.load_certificate(
|
@@ -150,7 +152,7 @@ class ZMQContextManager:
|
|
150
152
|
if asyncio:
|
151
153
|
self.context = zmq.asyncio.Context()
|
152
154
|
else:
|
153
|
-
self.context = zmq.Context
|
155
|
+
self.context = zmq.Context()
|
154
156
|
|
155
157
|
self.socket = self.context.socket(self.socket_type)
|
156
158
|
self.auth = None
|
@@ -175,6 +177,11 @@ class ZMQContextManager:
|
|
175
177
|
if self.server_public_key:
|
176
178
|
self.socket.curve_serverkey = self.server_public_key
|
177
179
|
self.socket.connect(self.connect)
|
180
|
+
if self.timeout:
|
181
|
+
timeout_ms = int(self.timeout * 1000)
|
182
|
+
self.socket.setsockopt(zmq.RCVTIMEO, timeout_ms)
|
183
|
+
self.socket.setsockopt(zmq.SNDTIMEO, timeout_ms)
|
184
|
+
self.socket.setsockopt(zmq.LINGER, 0)
|
178
185
|
return self.socket
|
179
186
|
|
180
187
|
def reload_certificates(self):
|
qulab/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.10.
|
1
|
+
__version__ = "2.10.8"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
qulab/__init__.py,sha256=WW0jUmIXEp_8cfLVUtg-C8COIDbZp0X9mIlz3suJkrU,407
|
2
2
|
qulab/__main__.py,sha256=fjaRSL_uUjNIzBGNgjlGswb9TJ2VD5qnkZHW3hItrD4,68
|
3
3
|
qulab/dicttree.py,sha256=QNClEGRFRFJIgAq9bUyxK4iPbkNRdZDona8UZq9jDfw,14236
|
4
|
-
qulab/expression.py,sha256=
|
5
|
-
qulab/fun.cpython-312-darwin.so,sha256=
|
4
|
+
qulab/expression.py,sha256=ZnTepyvhG2DUdOvCCny8jbeNCsvYi6G4xjdr05HxLuE,25751
|
5
|
+
qulab/fun.cpython-312-darwin.so,sha256=MTRGta9a8wIB7DI8pin_rPUNAF9c7rJNPAJCBMUxmRg,126864
|
6
6
|
qulab/typing.py,sha256=vg62sGqxuD9CI5677ejlzAmf2fVdAESZCQjAE_xSxPg,69
|
7
7
|
qulab/utils.py,sha256=BdLdlfjpe6m6gSeONYmpAKTTqxDaYHNk4exlz8kZxTg,2982
|
8
|
-
qulab/version.py,sha256=
|
8
|
+
qulab/version.py,sha256=v1ULYkz4y1F6VU70svKTuocAXtwJT06U9uYHUyHkGVA,22
|
9
9
|
qulab/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
qulab/cli/commands.py,sha256=F1LATmSC9lOAdnrOTMK7DRjETCEcOmMsocovWRyjWTc,597
|
11
11
|
qulab/cli/config.py,sha256=fWeWHiX-Oxodvfv4g0B-UFisJlYcF1Hv6V1fKib2mOM,5447
|
@@ -33,12 +33,12 @@ qulab/scan/__init__.py,sha256=Z88CzGsvr1VdKbF6aYgQv3j-fsEkKmqvpvX4LlzOM98,87
|
|
33
33
|
qulab/scan/curd.py,sha256=ZcwO5SKO95OcDgpUPDHcK5FW_BrJbUzuBk71UG_pqnM,6888
|
34
34
|
qulab/scan/models.py,sha256=JFofv-RH0gpS3--M6izXiQg7iGkS9a_em2DwhS5kTTk,17626
|
35
35
|
qulab/scan/optimize.py,sha256=VT9TpuqDkG7FdJJkYy60r5Pfrmjvfu5i36Ru6XvIiTI,2561
|
36
|
-
qulab/scan/query.py,sha256
|
36
|
+
qulab/scan/query.py,sha256=SM4N3YfUpWnocl_7WNj00ff8uNzRQINMK0RNfPoDcoc,12254
|
37
37
|
qulab/scan/record.py,sha256=yIHPANf6nuBXy8Igf-dMtGJ7wuFTLYlBaaAUc0AzwyU,21280
|
38
|
-
qulab/scan/scan.py,sha256=
|
39
|
-
qulab/scan/server.py,sha256=
|
38
|
+
qulab/scan/scan.py,sha256=m4EomeknN7MmNH-6M1mSmGHgz5QdkTkvHIkH6v66Bo4,39473
|
39
|
+
qulab/scan/server.py,sha256=Y1W3DysWBFQxR7-GoP95gvsf2SxRPY40GnONbmkQCu4,17188
|
40
40
|
qulab/scan/space.py,sha256=OQLepiNNP5TNYMHXeVFT59lL5n4soPmnMoMy_o9EHt0,6696
|
41
|
-
qulab/scan/utils.py,sha256=
|
41
|
+
qulab/scan/utils.py,sha256=38-rxQmMfKn1QVeScvyyGCk01dE2eE9ffPssdgtSCZA,6289
|
42
42
|
qulab/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
43
|
qulab/storage/__main__.py,sha256=3emxxRry8BB0m8hUZvJ_oBqkPy7ksV7flHB_KEDXZuI,1692
|
44
44
|
qulab/storage/base_dataset.py,sha256=4aKhqBNdZfdlm_z1Qy5dv0HrvgpvMdy8pbyfua8uE-4,11865
|
@@ -87,7 +87,7 @@ qulab/sys/rpc/server.py,sha256=e3R0gwOHpLEkSp7Tb43FMSDvqSG-pjrkskdISKQRseE,713
|
|
87
87
|
qulab/sys/rpc/socket.py,sha256=e3R0gwOHpLEkSp7Tb43FMSDvqSG-pjrkskdISKQRseE,713
|
88
88
|
qulab/sys/rpc/utils.py,sha256=6YGFOkY7o09lkA_I1FIP9_1Up3k2F1KOkftvu0_8lxo,594
|
89
89
|
qulab/sys/rpc/worker.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
90
|
-
qulab/sys/rpc/zmq_socket.py,sha256=
|
90
|
+
qulab/sys/rpc/zmq_socket.py,sha256=fyElXf0mghlKX7ZZKFoJgs043emfu1L7jr8DTzmEW20,8587
|
91
91
|
qulab/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
92
92
|
qulab/tools/connection_helper.py,sha256=o1t6UpJQPyj4mWY66axgQkgsqUzdkhEGBJo44x9U1iE,946
|
93
93
|
qulab/visualization/__init__.py,sha256=26cuHt3QIJXUb3VaMxlJx3IQTOUVJFKlYBZr7WMP53M,6129
|
@@ -99,9 +99,9 @@ qulab/visualization/plot_seq.py,sha256=UWTS6p9nfX_7B8ehcYo6UnSTUCjkBsNU9jiOeW2ca
|
|
99
99
|
qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
|
100
100
|
qulab/visualization/rot3d.py,sha256=lMrEJlRLwYe6NMBlGkKYpp_V9CTipOAuDy6QW_cQK00,734
|
101
101
|
qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
|
102
|
-
qulab-2.10.
|
103
|
-
qulab-2.10.
|
104
|
-
qulab-2.10.
|
105
|
-
qulab-2.10.
|
106
|
-
qulab-2.10.
|
107
|
-
qulab-2.10.
|
102
|
+
qulab-2.10.8.dist-info/licenses/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
|
103
|
+
qulab-2.10.8.dist-info/METADATA,sha256=qzJEbCW1HnzQss2hCBqLu2WHj0O9T0BkqkVeBlNbguo,3753
|
104
|
+
qulab-2.10.8.dist-info/WHEEL,sha256=Inq8GN4B3FxqLqMouJgNCh3_KlBp46ucqLBYqKIagAU,115
|
105
|
+
qulab-2.10.8.dist-info/entry_points.txt,sha256=b0v1GXOwmxY-nCCsPN_rHZZvY9CtTbWqrGj8u1m8yHo,45
|
106
|
+
qulab-2.10.8.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
|
107
|
+
qulab-2.10.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|