QuLab 2.2.8__tar.gz → 2.3.1__tar.gz

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.
Files changed (95) hide show
  1. {qulab-2.2.8 → qulab-2.3.1}/PKG-INFO +1 -1
  2. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/PKG-INFO +1 -1
  3. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/expression.py +106 -0
  4. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/optimize.py +12 -5
  5. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/record.py +3 -1
  6. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/scan.py +56 -17
  7. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/space.py +32 -8
  8. qulab-2.3.1/qulab/version.py +1 -0
  9. qulab-2.2.8/qulab/version.py +0 -1
  10. {qulab-2.2.8 → qulab-2.3.1}/LICENSE +0 -0
  11. {qulab-2.2.8 → qulab-2.3.1}/MANIFEST.in +0 -0
  12. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/SOURCES.txt +0 -0
  13. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/dependency_links.txt +0 -0
  14. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/entry_points.txt +0 -0
  15. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/requires.txt +0 -0
  16. {qulab-2.2.8 → qulab-2.3.1}/QuLab.egg-info/top_level.txt +0 -0
  17. {qulab-2.2.8 → qulab-2.3.1}/README.md +0 -0
  18. {qulab-2.2.8 → qulab-2.3.1}/pyproject.toml +0 -0
  19. {qulab-2.2.8 → qulab-2.3.1}/qulab/__init__.py +0 -0
  20. {qulab-2.2.8 → qulab-2.3.1}/qulab/__main__.py +0 -0
  21. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/__init__.py +0 -0
  22. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/__main__.py +0 -0
  23. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/config.py +0 -0
  24. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/dataset.py +0 -0
  25. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/event_queue.py +0 -0
  26. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/mainwindow.py +0 -0
  27. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/monitor.py +0 -0
  28. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/ploter.py +0 -0
  29. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/qt_compat.py +0 -0
  30. {qulab-2.2.8 → qulab-2.3.1}/qulab/monitor/toolbar.py +0 -0
  31. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/__init__.py +0 -0
  32. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/curd.py +0 -0
  33. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/models.py +0 -0
  34. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/query.py +0 -0
  35. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/server.py +0 -0
  36. {qulab-2.2.8 → qulab-2.3.1}/qulab/scan/utils.py +0 -0
  37. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/__init__.py +0 -0
  38. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/__main__.py +0 -0
  39. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/backend/__init__.py +0 -0
  40. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/backend/redis.py +0 -0
  41. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/base_dataset.py +0 -0
  42. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/chunk.py +0 -0
  43. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/dataset.py +0 -0
  44. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/file.py +0 -0
  45. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/__init__.py +0 -0
  46. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/base.py +0 -0
  47. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/config.py +0 -0
  48. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/file.py +0 -0
  49. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/ipy.py +0 -0
  50. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/models.py +0 -0
  51. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/record.py +0 -0
  52. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/report.py +0 -0
  53. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/models/tag.py +0 -0
  54. {qulab-2.2.8 → qulab-2.3.1}/qulab/storage/storage.py +0 -0
  55. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/__init__.py +0 -0
  56. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/chat.py +0 -0
  57. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/device/__init__.py +0 -0
  58. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/device/basedevice.py +0 -0
  59. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/device/loader.py +0 -0
  60. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/device/utils.py +0 -0
  61. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/drivers/FakeInstrument.py +0 -0
  62. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/drivers/__init__.py +0 -0
  63. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/ipy_events.py +0 -0
  64. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/__init__.py +0 -0
  65. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/bencoder.py +0 -0
  66. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/cli.py +0 -0
  67. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/dhcp.py +0 -0
  68. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/dhcpd.py +0 -0
  69. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/kad.py +0 -0
  70. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/kcp.py +0 -0
  71. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/net/nginx.py +0 -0
  72. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/progress.py +0 -0
  73. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/__init__.py +0 -0
  74. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/client.py +0 -0
  75. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/exceptions.py +0 -0
  76. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/msgpack.py +0 -0
  77. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/msgpack.pyi +0 -0
  78. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/rpc.py +0 -0
  79. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/serialize.py +0 -0
  80. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/server.py +0 -0
  81. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/socket.py +0 -0
  82. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/utils.py +0 -0
  83. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/worker.py +0 -0
  84. {qulab-2.2.8 → qulab-2.3.1}/qulab/sys/rpc/zmq_socket.py +0 -0
  85. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/__init__.py +0 -0
  86. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/__main__.py +0 -0
  87. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/_autoplot.py +0 -0
  88. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/plot_layout.py +0 -0
  89. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/plot_seq.py +0 -0
  90. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/qdat.py +0 -0
  91. {qulab-2.2.8 → qulab-2.3.1}/qulab/visualization/widgets.py +0 -0
  92. {qulab-2.2.8 → qulab-2.3.1}/setup.cfg +0 -0
  93. {qulab-2.2.8 → qulab-2.3.1}/setup.py +0 -0
  94. {qulab-2.2.8 → qulab-2.3.1}/src/qulab.h +0 -0
  95. {qulab-2.2.8 → qulab-2.3.1}/tests/test_scan.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: QuLab
3
- Version: 2.2.8
3
+ Version: 2.3.1
4
4
  Summary: contral instruments and manage data
5
5
  Author-email: feihoo87 <feihoo87@gmail.com>
6
6
  Maintainer-email: feihoo87 <feihoo87@gmail.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: QuLab
3
- Version: 2.2.8
3
+ Version: 2.3.1
4
4
  Summary: contral instruments and manage data
5
5
  Author-email: feihoo87 <feihoo87@gmail.com>
6
6
  Maintainer-email: feihoo87 <feihoo87@gmail.com>
@@ -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
 
@@ -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.recommend()
65
+ recommendation = self.opt.provide_recommendation()
59
66
  ret = OptimizeResult({
60
67
  'x': [
61
68
  space.inverse_transform(x)
@@ -589,7 +589,9 @@ class Record():
589
589
  return record
590
590
 
591
591
  def __repr__(self):
592
- return f"<Record: id={self.id} app={self.description['app']}, keys={self.keys()}>"
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"""
@@ -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
- return Symbol(name)
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'], self.description['optimizers'],
675
- self.description['setters'], self.description['getters']):
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
@@ -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
- return self.method(list(self.dimensions.values()), **self.kwds)
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) -> OptimizeSpace:
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) -> OptimizeSpace:
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) -> OptimizeSpace:
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()
@@ -0,0 +1 @@
1
+ __version__ = "2.3.1"
@@ -1 +0,0 @@
1
- __version__ = "2.2.8"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes