QuLab 2.2.8__cp310-cp310-macosx_10_9_universal2.whl → 2.3.1__cp310-cp310-macosx_10_9_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-2.2.8.dist-info → QuLab-2.3.1.dist-info}/METADATA +1 -1
- {QuLab-2.2.8.dist-info → QuLab-2.3.1.dist-info}/RECORD +13 -13
- {QuLab-2.2.8.dist-info → QuLab-2.3.1.dist-info}/WHEEL +1 -1
- qulab/fun.cpython-310-darwin.so +0 -0
- qulab/scan/expression.py +106 -0
- qulab/scan/optimize.py +12 -5
- qulab/scan/record.py +3 -1
- qulab/scan/scan.py +56 -17
- qulab/scan/space.py +32 -8
- qulab/version.py +1 -1
- {QuLab-2.2.8.dist-info → QuLab-2.3.1.dist-info}/LICENSE +0 -0
- {QuLab-2.2.8.dist-info → QuLab-2.3.1.dist-info}/entry_points.txt +0 -0
- {QuLab-2.2.8.dist-info → QuLab-2.3.1.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
qulab/__init__.py,sha256=P-Mx2p4TVmL91SoxoeXcj8Qm0x4xUf5Q_FLk0Yc_gIQ,138
|
|
2
2
|
qulab/__main__.py,sha256=ZC1NKaoxKyy60DaCfB8vYnB1z3RXQ2j8E1sRZ4A8sXE,428
|
|
3
|
-
qulab/fun.cpython-310-darwin.so,sha256=
|
|
4
|
-
qulab/version.py,sha256=
|
|
3
|
+
qulab/fun.cpython-310-darwin.so,sha256=VlJHvNsGpb8r_ZqQcd1fX7jR_Q5KnbIL-uSOP214K-0,159632
|
|
4
|
+
qulab/version.py,sha256=6STsl4r4R0vt1cK4ruxjle9q351XfLSSyARO42RdqOk,21
|
|
5
5
|
qulab/monitor/__init__.py,sha256=nTHelnDpxRS_fl_B38TsN0njgq8eVTEz9IAnN3NbDlM,42
|
|
6
6
|
qulab/monitor/__main__.py,sha256=w3yUcqq195LzSnXTkQcuC1RSFRhy4oQ_PEBmucXguME,97
|
|
7
7
|
qulab/monitor/config.py,sha256=fQ5JcsMApKc1UwANEnIvbDQZl8uYW0tle92SaYtX9lI,744
|
|
@@ -14,14 +14,14 @@ qulab/monitor/qt_compat.py,sha256=OK71_JSO_iyXjRIKHANmaK4Lx4bILUzmXI-mwKg3QeI,78
|
|
|
14
14
|
qulab/monitor/toolbar.py,sha256=WEag6cxAtEsOLL14XvM7pSE56EA3MO188_JuprNjdBs,7948
|
|
15
15
|
qulab/scan/__init__.py,sha256=ZX4WsvqYxvJeHLgGSrtJoAnVU94gxY7EHKMxYooMERg,130
|
|
16
16
|
qulab/scan/curd.py,sha256=thq_qfi3qng3Zx-1uhNG64IQhGCuum_LR4MOKnS8cDI,6896
|
|
17
|
-
qulab/scan/expression.py,sha256=
|
|
17
|
+
qulab/scan/expression.py,sha256=s2_sWFm4gKgJ7pGLmuugCU8XifAm9Mc3AT3bdoyFUtM,19459
|
|
18
18
|
qulab/scan/models.py,sha256=5Jpo25WGMWs0GtLzYLsWO61G3-FFYx5BHhBr2b6rOTE,17681
|
|
19
|
-
qulab/scan/optimize.py,sha256=
|
|
19
|
+
qulab/scan/optimize.py,sha256=jYceGazEabuwYqmZE8P6Nnq_KsLyUP0p-p88VbbJLhM,2559
|
|
20
20
|
qulab/scan/query.py,sha256=-5uHMhXSyGovK1oy_uUbGVEbRFzaMBkP78ZMNfI3jD0,11809
|
|
21
|
-
qulab/scan/record.py,sha256
|
|
22
|
-
qulab/scan/scan.py,sha256=
|
|
21
|
+
qulab/scan/record.py,sha256=sICMLAWf3IgvJ3JlS0cKQA4mSpLZins7K5qFoAnCSYI,21194
|
|
22
|
+
qulab/scan/scan.py,sha256=GXjx5gDT2L7S2H_opdFl9fEEJNsHi2RlwJpcbAY4aKg,37837
|
|
23
23
|
qulab/scan/server.py,sha256=ZT-J447xuLSpmbTNm5dNIz8_CXKOow66_bjkFNGh_vI,14274
|
|
24
|
-
qulab/scan/space.py,sha256=
|
|
24
|
+
qulab/scan/space.py,sha256=X5anTvw7X0XGN83y0o0C-zhvh6bDEU-kshGgo004pNE,6076
|
|
25
25
|
qulab/scan/utils.py,sha256=Pg_tCf3SUKTiPSBqb6Enkgx4bAyQJAkDGe9uYys1xVU,3613
|
|
26
26
|
qulab/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
qulab/storage/__main__.py,sha256=3emxxRry8BB0m8hUZvJ_oBqkPy7ksV7flHB_KEDXZuI,1692
|
|
@@ -78,9 +78,9 @@ qulab/visualization/plot_layout.py,sha256=clNw9QjE_kVNpIIx2Ob4YhAz2fucPGMuzkoIrO
|
|
|
78
78
|
qulab/visualization/plot_seq.py,sha256=lphYF4VhkEdc_wWr1kFBwrx2yujkyFPFaJ3pjr61awI,2693
|
|
79
79
|
qulab/visualization/qdat.py,sha256=ZeevBYWkzbww4xZnsjHhw7wRorJCBzbG0iEu-XQB4EA,5735
|
|
80
80
|
qulab/visualization/widgets.py,sha256=6KkiTyQ8J-ei70LbPQZAK35wjktY47w2IveOa682ftA,3180
|
|
81
|
-
QuLab-2.
|
|
82
|
-
QuLab-2.
|
|
83
|
-
QuLab-2.
|
|
84
|
-
QuLab-2.
|
|
85
|
-
QuLab-2.
|
|
86
|
-
QuLab-2.
|
|
81
|
+
QuLab-2.3.1.dist-info/LICENSE,sha256=PRzIKxZtpQcH7whTG6Egvzl1A0BvnSf30tmR2X2KrpA,1065
|
|
82
|
+
QuLab-2.3.1.dist-info/METADATA,sha256=86_MtpxRFwbah3FMBNV24Gsr_p05NkZo6Sx6904TtUw,3510
|
|
83
|
+
QuLab-2.3.1.dist-info/WHEEL,sha256=ClVOi9g10rI0HLG8M8rsO0ZIZ1smbNYM10V9YDSXCJY,114
|
|
84
|
+
QuLab-2.3.1.dist-info/entry_points.txt,sha256=ohBzutEnQimP_BZWiuXdSliu4QAYSHHcN0PZD8c7ZCY,46
|
|
85
|
+
QuLab-2.3.1.dist-info/top_level.txt,sha256=3T886LbAsbvjonu_TDdmgxKYUn939BVTRPxPl9r4cEg,6
|
|
86
|
+
QuLab-2.3.1.dist-info/RECORD,,
|
qulab/fun.cpython-310-darwin.so
CHANGED
|
Binary file
|
qulab/scan/expression.py
CHANGED
|
@@ -210,6 +210,16 @@ class Expression():
|
|
|
210
210
|
return -self
|
|
211
211
|
return BinaryExpression(other, self, operator.mul)
|
|
212
212
|
|
|
213
|
+
def __matmul__(self, other):
|
|
214
|
+
if isinstance(other, Expression):
|
|
215
|
+
other = other.eval(_default_env)
|
|
216
|
+
return BinaryExpression(self, other, operator.matmul)
|
|
217
|
+
|
|
218
|
+
def __rmatmul__(self, other):
|
|
219
|
+
if isinstance(other, Expression):
|
|
220
|
+
other = other.eval(_default_env)
|
|
221
|
+
return BinaryExpression(other, self, operator.matmul)
|
|
222
|
+
|
|
213
223
|
def __truediv__(self, other):
|
|
214
224
|
if isinstance(other, Expression):
|
|
215
225
|
other = other.eval(_default_env)
|
|
@@ -226,6 +236,34 @@ class Expression():
|
|
|
226
236
|
return 0
|
|
227
237
|
return BinaryExpression(other, self, operator.truediv)
|
|
228
238
|
|
|
239
|
+
def __floordiv__(self, other):
|
|
240
|
+
if isinstance(other, Expression):
|
|
241
|
+
other = other.eval(_default_env)
|
|
242
|
+
if isinstance(other, ConstType) and other == 1:
|
|
243
|
+
return self
|
|
244
|
+
if isinstance(other, ConstType) and other == -1:
|
|
245
|
+
return -self
|
|
246
|
+
return BinaryExpression(self, other, operator.floordiv)
|
|
247
|
+
|
|
248
|
+
def __rfloordiv__(self, other):
|
|
249
|
+
if isinstance(other, Expression):
|
|
250
|
+
other = other.eval(_default_env)
|
|
251
|
+
if isinstance(other, ConstType) and other == 0:
|
|
252
|
+
return 0
|
|
253
|
+
return BinaryExpression(other, self, operator.floordiv)
|
|
254
|
+
|
|
255
|
+
def __mod__(self, other):
|
|
256
|
+
if isinstance(other, Expression):
|
|
257
|
+
other = other.eval(_default_env)
|
|
258
|
+
if isinstance(other, ConstType) and other == 1:
|
|
259
|
+
return 0
|
|
260
|
+
return BinaryExpression(self, other, operator.mod)
|
|
261
|
+
|
|
262
|
+
def __rmod__(self, other):
|
|
263
|
+
if isinstance(other, Expression):
|
|
264
|
+
other = other.eval(_default_env)
|
|
265
|
+
return BinaryExpression(other, self, operator.mod)
|
|
266
|
+
|
|
229
267
|
def __pow__(self, other):
|
|
230
268
|
if isinstance(other, Expression):
|
|
231
269
|
other = other.eval(_default_env)
|
|
@@ -248,6 +286,21 @@ class Expression():
|
|
|
248
286
|
def __pos__(self):
|
|
249
287
|
return UnaryExpression(self, operator.pos)
|
|
250
288
|
|
|
289
|
+
def __abs__(self):
|
|
290
|
+
return UnaryExpression(self, operator.abs)
|
|
291
|
+
|
|
292
|
+
def __not__(self):
|
|
293
|
+
return UnaryExpression(self, operator.not_)
|
|
294
|
+
|
|
295
|
+
def __inv__(self):
|
|
296
|
+
return UnaryExpression(self, operator.inv)
|
|
297
|
+
|
|
298
|
+
def __invert__(self):
|
|
299
|
+
return UnaryExpression(self, operator.invert)
|
|
300
|
+
|
|
301
|
+
def __index__(self):
|
|
302
|
+
return UnaryExpression(self, operator.index)
|
|
303
|
+
|
|
251
304
|
def __eq__(self, other):
|
|
252
305
|
if isinstance(other, Expression):
|
|
253
306
|
other = other.eval(_default_env)
|
|
@@ -278,6 +331,56 @@ class Expression():
|
|
|
278
331
|
other = other.eval(_default_env)
|
|
279
332
|
return BinaryExpression(self, other, operator.ge)
|
|
280
333
|
|
|
334
|
+
def __and__(self, other):
|
|
335
|
+
if isinstance(other, Expression):
|
|
336
|
+
other = other.eval(_default_env)
|
|
337
|
+
return BinaryExpression(self, other, operator.and_)
|
|
338
|
+
|
|
339
|
+
def __rand__(self, other):
|
|
340
|
+
if isinstance(other, Expression):
|
|
341
|
+
other
|
|
342
|
+
return BinaryExpression(other, self, operator.and_)
|
|
343
|
+
|
|
344
|
+
def __or__(self, other):
|
|
345
|
+
if isinstance(other, Expression):
|
|
346
|
+
other = other.eval(_default_env)
|
|
347
|
+
return BinaryExpression(self, other, operator.or_)
|
|
348
|
+
|
|
349
|
+
def __ror__(self, other):
|
|
350
|
+
if isinstance(other, Expression):
|
|
351
|
+
other = other.eval(_default_env)
|
|
352
|
+
return BinaryExpression(other, self, operator.or_)
|
|
353
|
+
|
|
354
|
+
def __lshift__(self, other):
|
|
355
|
+
if isinstance(other, Expression):
|
|
356
|
+
other = other.eval(_default_env)
|
|
357
|
+
return BinaryExpression(self, other, operator.lshift)
|
|
358
|
+
|
|
359
|
+
def __rlshift__(self, other):
|
|
360
|
+
if isinstance(other, Expression):
|
|
361
|
+
other = other.eval(_default_env)
|
|
362
|
+
return BinaryExpression(other, self, operator.lshift)
|
|
363
|
+
|
|
364
|
+
def __rshift__(self, other):
|
|
365
|
+
if isinstance(other, Expression):
|
|
366
|
+
other = other.eval(_default_env)
|
|
367
|
+
return BinaryExpression(self, other, operator.rshift)
|
|
368
|
+
|
|
369
|
+
def __rrshift__(self, other):
|
|
370
|
+
if isinstance(other, Expression):
|
|
371
|
+
other = other.eval(_default_env)
|
|
372
|
+
return BinaryExpression(other, self, operator.rshift)
|
|
373
|
+
|
|
374
|
+
def __xor__(self, other):
|
|
375
|
+
if isinstance(other, Expression):
|
|
376
|
+
other = other.eval(_default_env)
|
|
377
|
+
return BinaryExpression(self, other, operator.xor)
|
|
378
|
+
|
|
379
|
+
def __rxor__(self, other):
|
|
380
|
+
if isinstance(other, Expression):
|
|
381
|
+
other = other.eval(_default_env)
|
|
382
|
+
return BinaryExpression(other, self, operator.xor)
|
|
383
|
+
|
|
281
384
|
def __getitem__(self, other):
|
|
282
385
|
if isinstance(other, Expression):
|
|
283
386
|
other = other.eval(_default_env)
|
|
@@ -301,6 +404,9 @@ class Expression():
|
|
|
301
404
|
def __round__(self, n=None):
|
|
302
405
|
return self
|
|
303
406
|
|
|
407
|
+
def __bool__(self):
|
|
408
|
+
return True
|
|
409
|
+
|
|
304
410
|
def eval(self, env):
|
|
305
411
|
raise NotImplementedError
|
|
306
412
|
|
qulab/scan/optimize.py
CHANGED
|
@@ -37,6 +37,12 @@ class NgOptimizer():
|
|
|
37
37
|
self.config['method'])(self.instrum,
|
|
38
38
|
budget=self.config['budget'])
|
|
39
39
|
|
|
40
|
+
def suggest(self, *suggested):
|
|
41
|
+
suggested = [
|
|
42
|
+
space.transform(x) for x, space in zip(suggested, self.dimensions)
|
|
43
|
+
]
|
|
44
|
+
self.opt.suggest(*suggested)
|
|
45
|
+
|
|
40
46
|
def ask(self):
|
|
41
47
|
tmp = self.opt.ask()
|
|
42
48
|
return [
|
|
@@ -47,15 +53,16 @@ class NgOptimizer():
|
|
|
47
53
|
def tell(self, suggested: Sequence, value: Any):
|
|
48
54
|
self._all_x.append(suggested)
|
|
49
55
|
self._all_y.append(value)
|
|
50
|
-
suggested = [
|
|
56
|
+
suggested = tuple([
|
|
51
57
|
space.transform(x) for x, space in zip(suggested, self.dimensions)
|
|
52
|
-
]
|
|
53
|
-
self.opt.suggest(*suggested)
|
|
54
|
-
x = self.opt.ask()
|
|
58
|
+
])
|
|
59
|
+
# self.opt.suggest(*suggested)
|
|
60
|
+
# x = self.opt.ask()
|
|
61
|
+
x = self.instrum.spawn_child(new_value=(suggested, {}))
|
|
55
62
|
self.opt.tell(x, value)
|
|
56
63
|
|
|
57
64
|
def get_result(self, history: bool = False) -> OptimizeResult:
|
|
58
|
-
recommendation = self.opt.
|
|
65
|
+
recommendation = self.opt.provide_recommendation()
|
|
59
66
|
ret = OptimizeResult({
|
|
60
67
|
'x': [
|
|
61
68
|
space.inverse_transform(x)
|
qulab/scan/record.py
CHANGED
|
@@ -589,7 +589,9 @@ class Record():
|
|
|
589
589
|
return record
|
|
590
590
|
|
|
591
591
|
def __repr__(self):
|
|
592
|
-
|
|
592
|
+
if self.is_remote_record() and not self._items:
|
|
593
|
+
self._items = {key: None for key in self.keys()}
|
|
594
|
+
return f"<Record: id={self.id} app={self.description['app']}, keys={self._items.keys()}>"
|
|
593
595
|
|
|
594
596
|
# def _repr_html_(self):
|
|
595
597
|
# return f"""
|
qulab/scan/scan.py
CHANGED
|
@@ -226,10 +226,11 @@ class Scan():
|
|
|
226
226
|
max_workers: int = 4,
|
|
227
227
|
max_promise: int = 100,
|
|
228
228
|
max_message: int = 1000,
|
|
229
|
+
config: dict | None = None,
|
|
229
230
|
mixin=None):
|
|
230
231
|
self.id = task_uuid()
|
|
231
232
|
self.record = None
|
|
232
|
-
self.config = None
|
|
233
|
+
self.config = {} if config is None else copy.deepcopy(config)
|
|
233
234
|
self.description = {
|
|
234
235
|
'app': app,
|
|
235
236
|
'tags': tags,
|
|
@@ -250,7 +251,7 @@ class Scan():
|
|
|
250
251
|
'filters': {},
|
|
251
252
|
'total': {},
|
|
252
253
|
'database': database,
|
|
253
|
-
'hiden': ['self', r'^__.*', r'.*__$'],
|
|
254
|
+
'hiden': ['self', 'config', r'^__.*', r'.*__$'],
|
|
254
255
|
'entry': {
|
|
255
256
|
'system': get_system_info(),
|
|
256
257
|
'env': {},
|
|
@@ -392,7 +393,10 @@ class Scan():
|
|
|
392
393
|
if name in self.description['consts']:
|
|
393
394
|
return self.description['consts'][name]
|
|
394
395
|
else:
|
|
395
|
-
|
|
396
|
+
try:
|
|
397
|
+
return self._query_config(name)
|
|
398
|
+
except:
|
|
399
|
+
return Symbol(name)
|
|
396
400
|
|
|
397
401
|
def _add_search_space(self, name: str, level: int, space):
|
|
398
402
|
if level not in self.description['loops']:
|
|
@@ -402,6 +406,8 @@ class Scan():
|
|
|
402
406
|
def add_depends(self, name: str, depends: list[str]):
|
|
403
407
|
if isinstance(depends, str):
|
|
404
408
|
depends = [depends]
|
|
409
|
+
if 'self' in depends:
|
|
410
|
+
depends.append('config')
|
|
405
411
|
if name not in self.description['dependents']:
|
|
406
412
|
self.description['dependents'][name] = set()
|
|
407
413
|
self.description['dependents'][name].update(depends)
|
|
@@ -448,6 +454,9 @@ class Scan():
|
|
|
448
454
|
pass
|
|
449
455
|
self.description['consts'][name] = value
|
|
450
456
|
|
|
457
|
+
if '.' in name:
|
|
458
|
+
self.add_depends('config', [name])
|
|
459
|
+
|
|
451
460
|
if ',' in name:
|
|
452
461
|
for key in name.split(','):
|
|
453
462
|
if not key.startswith('*'):
|
|
@@ -472,6 +481,8 @@ class Scan():
|
|
|
472
481
|
elif isinstance(space, OptimizeSpace):
|
|
473
482
|
space.name = name
|
|
474
483
|
space.optimizer.dimensions[name] = space.space
|
|
484
|
+
if space.suggestions:
|
|
485
|
+
space.optimizer.suggestions[name] = space.suggestions
|
|
475
486
|
self._add_search_space(name, space.optimizer.level, space)
|
|
476
487
|
self.add_depends(space.optimizer.name, [name])
|
|
477
488
|
else:
|
|
@@ -486,6 +497,8 @@ class Scan():
|
|
|
486
497
|
self.add_depends(name, space.symbols())
|
|
487
498
|
if setter:
|
|
488
499
|
self.description['setters'][name] = setter
|
|
500
|
+
if '.' in name:
|
|
501
|
+
self.add_depends('config', [name])
|
|
489
502
|
|
|
490
503
|
def trace(self,
|
|
491
504
|
name: str,
|
|
@@ -535,6 +548,28 @@ class Scan():
|
|
|
535
548
|
self.description['getters'][name] = getter
|
|
536
549
|
return opt
|
|
537
550
|
|
|
551
|
+
def _synchronize_config(self):
|
|
552
|
+
for key, value in self.variables.items():
|
|
553
|
+
if '.' in key:
|
|
554
|
+
d = self.config
|
|
555
|
+
ks = key.split('.')
|
|
556
|
+
if not ks:
|
|
557
|
+
continue
|
|
558
|
+
for k in ks[:-1]:
|
|
559
|
+
if k in d:
|
|
560
|
+
d = d[k]
|
|
561
|
+
else:
|
|
562
|
+
d[k] = {}
|
|
563
|
+
d = d[k]
|
|
564
|
+
d[ks[-1]] = value
|
|
565
|
+
return self.config
|
|
566
|
+
|
|
567
|
+
def _query_config(self, key):
|
|
568
|
+
d = self.config
|
|
569
|
+
for k in key.split('.'):
|
|
570
|
+
d = d[k]
|
|
571
|
+
return d
|
|
572
|
+
|
|
538
573
|
async def _update_progress(self):
|
|
539
574
|
while True:
|
|
540
575
|
task = await self._prm_queue.get()
|
|
@@ -549,17 +584,6 @@ class Scan():
|
|
|
549
584
|
|
|
550
585
|
async def run(self):
|
|
551
586
|
assymbly(self.description)
|
|
552
|
-
if self.config:
|
|
553
|
-
self.description['config'] = await create_config(
|
|
554
|
-
self.config, self.description['database'], self._sock)
|
|
555
|
-
if current_notebook() is None:
|
|
556
|
-
await create_notebook('untitle', self.description['database'],
|
|
557
|
-
self._sock)
|
|
558
|
-
cell_id = await save_input_cells(current_notebook(),
|
|
559
|
-
self.description['entry']['scripts'],
|
|
560
|
-
self.description['database'],
|
|
561
|
-
self._sock)
|
|
562
|
-
self.description['entry']['scripts'] = cell_id
|
|
563
587
|
if isinstance(
|
|
564
588
|
self.description['database'],
|
|
565
589
|
str) and self.description['database'].startswith("tcp://"):
|
|
@@ -567,15 +591,28 @@ class Scan():
|
|
|
567
591
|
connect=self.description['database'],
|
|
568
592
|
socket=self._sock) as socket:
|
|
569
593
|
self._sock = socket
|
|
594
|
+
if self.config:
|
|
595
|
+
self.description['config'] = await create_config(
|
|
596
|
+
self.config, self.description['database'], self._sock)
|
|
597
|
+
if current_notebook() is None:
|
|
598
|
+
await create_notebook('untitle',
|
|
599
|
+
self.description['database'],
|
|
600
|
+
self._sock)
|
|
601
|
+
cell_id = await save_input_cells(
|
|
602
|
+
current_notebook(), self.description['entry']['scripts'],
|
|
603
|
+
self.description['database'], self._sock)
|
|
604
|
+
self.description['entry']['scripts'] = cell_id
|
|
570
605
|
await self._run()
|
|
571
606
|
else:
|
|
607
|
+
if self.config:
|
|
608
|
+
self.description['config'] = copy.deepcopy(self.config)
|
|
572
609
|
await self._run()
|
|
573
610
|
|
|
574
611
|
async def _run(self):
|
|
575
612
|
send_msg_task = asyncio.create_task(self._send_msg())
|
|
576
613
|
update_progress_task = asyncio.create_task(self._update_progress())
|
|
577
614
|
|
|
578
|
-
self._variables = {'self': self}
|
|
615
|
+
self._variables = {'self': self, 'config': self.config}
|
|
579
616
|
|
|
580
617
|
consts = {}
|
|
581
618
|
for k, v in self.description['consts'].items():
|
|
@@ -671,8 +708,10 @@ class Scan():
|
|
|
671
708
|
self.variables,
|
|
672
709
|
self.description['loops'].get(self.current_level, []),
|
|
673
710
|
self.description['order'].get(self.current_level, []),
|
|
674
|
-
self.description['functions']
|
|
675
|
-
|
|
711
|
+
self.description['functions']
|
|
712
|
+
| {'config': self._synchronize_config},
|
|
713
|
+
self.description['optimizers'], self.description['setters'],
|
|
714
|
+
self.description['getters']):
|
|
676
715
|
self._current_level += 1
|
|
677
716
|
if await self._filter(variables, self.current_level - 1):
|
|
678
717
|
yield variables
|
qulab/scan/space.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import itertools
|
|
1
2
|
from typing import Type
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
@@ -103,10 +104,14 @@ def geomspace(start, stop, num=50, endpoint=True):
|
|
|
103
104
|
|
|
104
105
|
class OptimizeSpace():
|
|
105
106
|
|
|
106
|
-
def __init__(self, optimizer: 'Optimizer', space):
|
|
107
|
+
def __init__(self, optimizer: 'Optimizer', space, suggestion=None):
|
|
107
108
|
self.optimizer = optimizer
|
|
108
109
|
self.space = space
|
|
109
110
|
self.name = None
|
|
111
|
+
if suggestion is not None and not isinstance(
|
|
112
|
+
suggestion, (list, tuple, np.ndarray)):
|
|
113
|
+
suggestion = [suggestion]
|
|
114
|
+
self.suggestion = suggestion
|
|
110
115
|
|
|
111
116
|
def __len__(self):
|
|
112
117
|
return self.optimizer.maxiter
|
|
@@ -130,17 +135,32 @@ class Optimizer():
|
|
|
130
135
|
self.level = level
|
|
131
136
|
self.kwds = kwds
|
|
132
137
|
self.minimize = minimize
|
|
138
|
+
self.suggestion = {}
|
|
133
139
|
|
|
134
140
|
def create(self):
|
|
135
|
-
|
|
141
|
+
opt = self.method(list(self.dimensions.values()), **self.kwds)
|
|
142
|
+
|
|
143
|
+
def rvs(space):
|
|
144
|
+
while True:
|
|
145
|
+
yield space.rvs()[0]
|
|
146
|
+
|
|
147
|
+
if self.suggestion:
|
|
148
|
+
for suggestion in zip(*[
|
|
149
|
+
self.suggestion.get(key, rvs(space))
|
|
150
|
+
for key, space in self.dimensions.items()
|
|
151
|
+
]):
|
|
152
|
+
opt.suggest(*suggestion)
|
|
153
|
+
return opt
|
|
136
154
|
|
|
137
155
|
def Categorical(self,
|
|
138
156
|
categories,
|
|
139
157
|
prior=None,
|
|
140
158
|
transform=None,
|
|
141
|
-
name=None
|
|
159
|
+
name=None,
|
|
160
|
+
suggestion=None) -> OptimizeSpace:
|
|
142
161
|
return OptimizeSpace(self,
|
|
143
|
-
Categorical(categories, prior, transform, name)
|
|
162
|
+
Categorical(categories, prior, transform, name),
|
|
163
|
+
suggestion)
|
|
144
164
|
|
|
145
165
|
def Integer(self,
|
|
146
166
|
low,
|
|
@@ -149,9 +169,11 @@ class Optimizer():
|
|
|
149
169
|
base=10,
|
|
150
170
|
transform="normalize",
|
|
151
171
|
name=None,
|
|
152
|
-
dtype=np.int64
|
|
172
|
+
dtype=np.int64,
|
|
173
|
+
suggestion=None) -> OptimizeSpace:
|
|
153
174
|
return OptimizeSpace(
|
|
154
|
-
self, Integer(low, high, prior, base, transform, name, dtype)
|
|
175
|
+
self, Integer(low, high, prior, base, transform, name, dtype),
|
|
176
|
+
suggestion)
|
|
155
177
|
|
|
156
178
|
def Real(self,
|
|
157
179
|
low,
|
|
@@ -160,9 +182,11 @@ class Optimizer():
|
|
|
160
182
|
base=10,
|
|
161
183
|
transform="normalize",
|
|
162
184
|
name=None,
|
|
163
|
-
dtype=float
|
|
185
|
+
dtype=float,
|
|
186
|
+
suggestion=None) -> OptimizeSpace:
|
|
164
187
|
return OptimizeSpace(
|
|
165
|
-
self, Real(low, high, prior, base, transform, name, dtype)
|
|
188
|
+
self, Real(low, high, prior, base, transform, name, dtype),
|
|
189
|
+
suggestion)
|
|
166
190
|
|
|
167
191
|
def __getstate__(self) -> dict:
|
|
168
192
|
state = self.__dict__.copy()
|
qulab/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.3.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|