luna-quantum 1.0.0__cp313-cp313-win_amd64.whl → 1.0.1rc10__cp313-cp313-win_amd64.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 luna-quantum might be problematic. Click here for more details.

Files changed (40) hide show
  1. luna_quantum/__init__.py +32 -17
  2. luna_quantum/__init__.pyi +23 -14
  3. luna_quantum/_core.cp313-win_amd64.pyd +0 -0
  4. luna_quantum/_core.pyi +1041 -375
  5. luna_quantum/algorithms/__init__.py +1 -0
  6. luna_quantum/backends/__init__.py +1 -0
  7. luna_quantum/client/rest_client/qpu_token_rest_client.py +7 -3
  8. luna_quantum/client/schemas/circuit.py +5 -6
  9. luna_quantum/client/schemas/create/__init__.py +10 -1
  10. luna_quantum/client/schemas/create/circuit.py +5 -6
  11. luna_quantum/client/schemas/create/qpu_token.py +2 -5
  12. luna_quantum/client/schemas/create/qpu_token_time_quota.py +3 -6
  13. luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +15 -0
  14. luna_quantum/client/schemas/create/solve_job_create.py +1 -1
  15. luna_quantum/client/schemas/qpu_token/qpu_token.py +9 -16
  16. luna_quantum/client/schemas/qpu_token/token_provider.py +3 -6
  17. luna_quantum/errors.py +34 -1
  18. luna_quantum/errors.pyi +83 -26
  19. luna_quantum/solve/domain/solve_job.py +2 -2
  20. luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +1 -0
  21. luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +4 -2
  22. luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +38 -22
  23. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +4 -2
  24. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +1 -3
  25. luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +2 -3
  26. luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +0 -16
  27. luna_quantum/solve/parameters/backends/__init__.py +1 -1
  28. luna_quantum/solve/parameters/backends/dwave_qpu.py +4 -2
  29. luna_quantum/solve/parameters/backends/ibm.py +8 -2
  30. luna_quantum/solve/parameters/backends/qctrl.py +4 -3
  31. luna_quantum/solve/use_cases/hamiltonian_cycle.py +2 -2
  32. luna_quantum/solve/usecases/solve_job_get_result_usecase.py +1 -3
  33. luna_quantum/translator.py +23 -1
  34. luna_quantum/translator.pyi +76 -43
  35. luna_quantum/utils.py +29 -11
  36. {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/METADATA +2 -4
  37. {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/RECORD +40 -37
  38. {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/WHEEL +1 -1
  39. {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/licenses/LICENSE +1 -1
  40. {luna_quantum-1.0.0.dist-info → luna_quantum-1.0.1rc10.dist-info}/licenses/NOTICE +0 -0
@@ -39,9 +39,7 @@ class QAOA(LunaAlgorithm[AWS | IonQ | IQM | Rigetti | IBM]):
39
39
  optimizer : ScipyOptimizerParams | Dict
40
40
  Configuration for the classical optimization routine that updates the
41
41
  variational parameters. Default is a ScipyOptimizer instance with default
42
- settings. See ScipyOptimizer class or
43
- https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
44
- for details of contained parameters.
42
+ settings. See ScipyOptimizerParams class for details of contained parameters.
45
43
  initial_params: LinearQAOAParams | BasicQAOAParams | RandomQAOAParams | Dict
46
44
  Custom QAOA variational circuit parameters. By default linear
47
45
  increasing/decreasing parameters for the selected `reps` are generated.
@@ -40,9 +40,8 @@ class VQE(LunaAlgorithm[IBM]):
40
40
  optimizer : ScipyOptimizerParams | Dict
41
41
  Configuration for the classical optimization routine that updates the
42
42
  variational parameters. Default is a ScipyOptimizer instance with default
43
- settings. See ScipyOptimizer class or
44
- https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
45
- for details of contained parameters.
43
+ settings. See ScipyOptimizer Params class or for details
44
+ of contained parameters.
46
45
  initial_params_seed: int | None
47
46
  Seed for random number generator for intial params.
48
47
  initial_params_range: tuple[float, float]
@@ -72,22 +72,6 @@ class DialecticSearch(LunaAlgorithm[DWave]):
72
72
  decomposer: Decomposer
73
73
  Decomposer: Breaks down problems into subproblems of manageable size
74
74
  Default is a Decomposer instance with default settings.
75
-
76
- Notes
77
- -----
78
- The Dialectic Search algorithm operates through two distinct phases:
79
-
80
- 1. Antithesis: Generates a complementary solution designed to explore different
81
- regions of the solution space
82
- 2. Synthesis: Creates new solutions by exploring paths between thesis and antithesis
83
-
84
- Each phase uses tabu search with potentially different parameter settings to
85
- guide the exploration process. This approach is particularly effective for
86
- problems with complex landscapes containing many local optima.
87
-
88
- The algorithm uses D-Wave's backend technology to efficiently solve optimization
89
- problems. For more details on D-Wave solvers, see:
90
- https://docs.dwavesys.com/
91
75
  """
92
76
 
93
77
  antithesis_tabu_params: TabuSearchBaseParams = Field(
@@ -6,7 +6,7 @@ from .ibm import IBM
6
6
  from .qctrl import Qctrl
7
7
  from .zib import ZIB
8
8
 
9
- __all__ = [
9
+ __all__: list[str] = [
10
10
  "AWS",
11
11
  "IBM",
12
12
  "IQM",
@@ -19,10 +19,10 @@ class DWaveQpu(DWave, QpuTokenBackend):
19
19
 
20
20
  Attributes
21
21
  ----------
22
- embedding_parameters: Embedding | None, default=None
22
+ embedding_parameters: Embedding | AutoEmbedding | None
23
23
  Detailed configuration for manual embedding when not using auto-embedding.
24
24
  If None and decomposer is also None, default embedding parameters will be used.
25
- Ignored if decomposer is set to AutoEmbedding.
25
+ Ignored if decomposer is set to AutoEmbedding. Default is None.
26
26
  qpu_backend: str
27
27
  Specific D-Wave quantum processing unit (QPU) for your optimization
28
28
  """
@@ -76,8 +76,10 @@ class DWaveQpu(DWave, QpuTokenBackend):
76
76
 
77
77
  return_overlap: bool, default=False
78
78
  Controls return value format:
79
+
79
80
  - True: Returns (embedding, validity_flag) tuple
80
81
  - False: Returns only the embedding
82
+
81
83
  This function returns an embedding regardless of whether qubits are used by
82
84
  multiple variables.
83
85
 
@@ -25,7 +25,7 @@ class IBM(IBackend):
25
25
  """
26
26
 
27
27
  class SimulatorBackend(BaseModel):
28
- """Simulator.
28
+ """Qiskit Statevector Simulator.
29
29
 
30
30
  Use a simulator as backend. The QAOA is executed completely on our server, and
31
31
  no IBM token is required.
@@ -41,7 +41,13 @@ class IBM(IBackend):
41
41
  backend_name: Literal["aer", "statevector"] = "aer"
42
42
 
43
43
  class FakeProviderBackend(BaseModel):
44
- """FaleProvider.
44
+ """Simulator with emulated QPU noise model.
45
+
46
+ The Qiskit fake provider runs a simulation with a noise model derived from
47
+ an actual QPU hardware implementation.
48
+ See [IBM documentation](
49
+ https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/fake-provider) for
50
+ available “fake” devices.
45
51
 
46
52
  Use a V2 fake backend from `qiskit_ibm_runtime.fake_provider`. The QAOA is
47
53
  executed entirely on our server, and no IBM token is required.
@@ -33,10 +33,10 @@ class Qctrl(QpuTokenBackend):
33
33
  - 'basic_simulator': Uses the basic simulator (default if None)
34
34
  Check your IBM Quantum account for available backends.
35
35
 
36
- ibm_credentials: QCtrl.IBMQ | QCtrl.IBMCloud, default=Qctrl.IBMQ()
36
+ ibm_credentials: IBMQ | IBMCloud
37
37
  The IBM backend credentials, i.e. how to access the IBM service. Q-Ctrl
38
38
  currently supports two mehtods, via the old IBMQ pattern or the new IBMCloud
39
- pattern.
39
+ pattern. Default is Qctrl.IBMQ()
40
40
 
41
41
  token: QpuToken | str | None, default=None
42
42
  The Q-Ctrl API token.
@@ -45,7 +45,8 @@ class Qctrl(QpuTokenBackend):
45
45
  Notes
46
46
  -----
47
47
  For detailed information about Fire Opal's QAOA solver and its capabilities,
48
- see Q-CTRL's documentation: https://docs.q-ctrl.com/fire-opal/topics/fire-opals-qaoa-solver
48
+ see [Q-CTRL's documentation](
49
+ https://docs.q-ctrl.com/fire-opal/topics/fire-opals-qaoa-solver)
49
50
  """
50
51
 
51
52
  class IBMQ(BaseModel):
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Final, Literal
3
+ from typing import Literal
4
4
 
5
5
  from pydantic import Field
6
6
 
@@ -46,4 +46,4 @@ class HamiltonianCycle(UseCase):
46
46
  graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
47
47
  directed: bool | None = False
48
48
  A: float = 1.0
49
- B: Final[float] = 0.0
49
+ B: float = 0.0
@@ -82,9 +82,7 @@ class SolveJobGetResultUseCase(ISolveJobGetResultUseCase):
82
82
  return None
83
83
  if solve_job.status == StatusEnum.FAILED:
84
84
  self.logger.error(
85
- "Solve job is failed."
86
- " See 'error_message'"
87
- " field in solve job object for further information."
85
+ f"Solve job failed with the error '{solve_job.error_message}'."
88
86
  )
89
87
  return None
90
88
  aq_solution: Solution = self.client.solve_job.get_solution(
@@ -1 +1,23 @@
1
- from ._core.translator import * # type: ignore[reportMissingImports, import-not-found,unused-ignore] # noqa: F403
1
+ """Translator collection.
2
+
3
+ The `translator` module provides a collection of translators for converting between
4
+ various formats related to optimization problems and their solutions.
5
+
6
+ Translators are categorized into two main groups:
7
+
8
+ 1. **Model Translators**: These handle conversions *to* and *from* the internal `Model`
9
+ representation. They enable interoperability between external formats
10
+ (e.g., QUBO, LP) and the standardized internal model format used within the system.
11
+
12
+ 2. **Solution Translators**: These support conversion *from* external solution formats
13
+ into the internal `Solution` representation. This enables solutions generated by
14
+ different solvers or formats to be interpreted and processed consistently within
15
+ the system. Note that these translators do not support conversion *from* the internal
16
+ solution to external formats.
17
+
18
+ Each translator encapsulates the logic needed for bidirectional format conversion,
19
+ ensuring consistency and modularity when integrating with diverse optimization
20
+ frameworks and solvers.
21
+ """
22
+
23
+ from ._core.translator import * # type: ignore[reportMissingImports] # noqa: F403
@@ -17,8 +17,8 @@ class ZibTranslator:
17
17
 
18
18
  - Convert a Zib-style solution into our solution `Solution`.
19
19
 
20
- The conversions are especially required when interacting with external zib solvers/samplers or
21
- libraries that operate on zib-based problem-solving/sampling.
20
+ The conversions are especially required when interacting with external zib
21
+ solvers/samplers or libraries that operate on zib-based problem-solving/sampling.
22
22
 
23
23
  Examples
24
24
  --------
@@ -63,8 +63,8 @@ class ZibTranslator:
63
63
  NoActiveEnvironmentFoundError
64
64
  If no environment is passed to the method or available from the context.
65
65
  SolutionTranslationError
66
- Generally if the solution translation fails. Might be specified by one of the
67
- two following errors.
66
+ Generally if the solution translation fails. Might be specified by one of
67
+ the two following errors.
68
68
  SampleIncorrectLengthError
69
69
  If a solution's sample has a different number of variables than the model
70
70
  environment passed to the translator.
@@ -72,10 +72,13 @@ class ZibTranslator:
72
72
  If the result's variable types are incompatible with the model environment's
73
73
  variable types.
74
74
  """
75
+ ...
75
76
 
76
77
  class Qubo:
77
- """
78
- A wrapper around qubo matrices that holds all relevant metadata, e.g., the model offset.
78
+ """The result of the QuboTranslator.
79
+
80
+ A wrapper around qubo matrices that holds all relevant metadata,
81
+ e.g., the model offset.
79
82
  """
80
83
 
81
84
  @property
@@ -89,6 +92,7 @@ class Qubo:
89
92
  A square NumPy array representing the QUBO matrix derived from
90
93
  the model's objective.
91
94
  """
95
+ ...
92
96
 
93
97
  @property
94
98
  def variable_names(self, /) -> list[str]:
@@ -100,6 +104,7 @@ class Qubo:
100
104
  list[Variable]
101
105
  The variable names in the order they appear in the QUBO.
102
106
  """
107
+ ...
103
108
 
104
109
  @property
105
110
  def name(self, /) -> str:
@@ -111,6 +116,7 @@ class Qubo:
111
116
  str
112
117
  The model name.
113
118
  """
119
+ ...
114
120
 
115
121
  @property
116
122
  def offset(self, /) -> float:
@@ -122,6 +128,7 @@ class Qubo:
122
128
  float
123
129
  The constant offset of the model.
124
130
  """
131
+ ...
125
132
 
126
133
  @property
127
134
  def vtype(self, /) -> Vtype:
@@ -133,6 +140,7 @@ class Qubo:
133
140
  Vtype
134
141
  The variable type.
135
142
  """
143
+ ...
136
144
 
137
145
  class QuboTranslator:
138
146
  """
@@ -148,7 +156,7 @@ class QuboTranslator:
148
156
  Examples
149
157
  --------
150
158
  >>> import numpy as np
151
- >>> from luna_quantum import QuboTranslator, Vtype
159
+ >>> from luna_quantum.translator import QuboTranslator, Vtype
152
160
  >>> q = np.array([[1.0, -1.0], [-1.0, 2.0]])
153
161
 
154
162
  Create a model from a matrix:
@@ -200,6 +208,7 @@ class QuboTranslator:
200
208
  If a list of variable names is provided but contains duplicates or has an
201
209
  incorrect length.
202
210
  """
211
+ ...
203
212
 
204
213
  @staticmethod
205
214
  def from_aq(model: Model) -> Qubo:
@@ -215,9 +224,10 @@ class QuboTranslator:
215
224
  Returns
216
225
  -------
217
226
  Qubo
218
- An object representing a QUBO with information additional to the square NumPy array
219
- representing the QUBO matrix derived from the model's objective. This object also
220
- includes the `variable_ordering` as well as the `offset` of the original model.
227
+ An object representing a QUBO with information additional to the square
228
+ NumPy array representing the QUBO matrix derived from the model's objective.
229
+ This object also includes the `variable_ordering` as well as the `offset`
230
+ of the original model.
221
231
 
222
232
  Raises
223
233
  ------
@@ -234,6 +244,7 @@ class QuboTranslator:
234
244
  If the model contains different vtypes or vtypes other than binary and
235
245
  spin.
236
246
  """
247
+ ...
237
248
 
238
249
  class QctrlTranslator:
239
250
  """
@@ -242,8 +253,8 @@ class QctrlTranslator:
242
253
  `QctrlTranslator` provides methods to:
243
254
  - Convert a Qctrl-style solution into our solution `Solution`.
244
255
 
245
- The conversions are especially required when interacting with external qctrl solvers/samplers or
246
- libraries that operate on qctrl-based problem-solving/sampling.
256
+ The conversions are especially required when interacting with external qctrl
257
+ solvers/samplers or libraries that operate on qctrl-based problem-solving/sampling.
247
258
 
248
259
  Examples
249
260
  --------
@@ -291,8 +302,8 @@ class QctrlTranslator:
291
302
  NoActiveEnvironmentFoundError
292
303
  If no environment is passed to the method or available from the context.
293
304
  SolutionTranslationError
294
- Generally if the solution translation fails. Might be specified by one of the
295
- two following errors.
305
+ Generally if the solution translation fails. Might be specified by one of
306
+ the two following errors.
296
307
  SampleIncorrectLengthError
297
308
  If a solution's sample has a different number of variables than the model
298
309
  environment passed to the translator.
@@ -300,11 +311,13 @@ class QctrlTranslator:
300
311
  If the result's variable types are incompatible with the model environment's
301
312
  variable types.
302
313
  """
314
+ ...
303
315
 
304
316
  class NumpyTranslator:
305
- """
306
- Utility class for converting between a result consisting of numpy arrays and our solution
307
- format.
317
+ """Translate between numpy arrays and our solution format.
318
+
319
+ Utility class for converting between a result consisting of numpy arrays and our
320
+ solution format.
308
321
 
309
322
  `NumpyTranslator` provides methods to:
310
323
  - Convert a numpy-array result into our solution `Solution`.
@@ -341,7 +354,8 @@ class NumpyTranslator:
341
354
  env: Environment | None = ...,
342
355
  ) -> Solution:
343
356
  """
344
- Convert an IBM solution to our solution format.
357
+ Convert a solution in the format of numpy arrays to our solution format.
358
+ Note that the optimization sense is always assumed to be minimization.
345
359
 
346
360
  Parameters
347
361
  ----------
@@ -359,8 +373,8 @@ class NumpyTranslator:
359
373
  NoActiveEnvironmentFoundError
360
374
  If no environment is passed to the method or available from the context.
361
375
  SolutionTranslationError
362
- Generally if the solution translation fails. Might be specified by one of the
363
- two following errors.
376
+ Generally if the solution translation fails. Might be specified by one of
377
+ the two following errors.
364
378
  SampleIncorrectLengthError
365
379
  If a solution's sample has a different number of variables than the model
366
380
  environment passed to the translator.
@@ -368,6 +382,7 @@ class NumpyTranslator:
368
382
  If the result's variable types are incompatible with the model environment's
369
383
  variable types.
370
384
  """
385
+ ...
371
386
 
372
387
  class LpTranslator:
373
388
  """
@@ -383,7 +398,7 @@ class LpTranslator:
383
398
  Examples
384
399
  --------
385
400
  >>> from pathlib import Path
386
- >>> from luna_quantum import LpTranslator
401
+ >>> from luna_quantum.translator import LpTranslator
387
402
  >>> lp_filepath = Path("path/to/the/lp_file")
388
403
 
389
404
  >>> model = LpTranslator.to_aq(lp_filepath)
@@ -398,7 +413,9 @@ class LpTranslator:
398
413
  def to_aq(file: Path) -> Model: ...
399
414
  @overload
400
415
  @staticmethod
401
- def to_aq(file: str) -> Model:
416
+ def to_aq(file: str) -> Model: ...
417
+ @staticmethod
418
+ def to_aq(file: str | Path) -> Model:
402
419
  """
403
420
  Convert an LP file into a symbolic `Model`.
404
421
 
@@ -422,13 +439,16 @@ class LpTranslator:
422
439
  TranslationError
423
440
  If the translation fails for a different reason.
424
441
  """
442
+ ...
425
443
 
426
444
  @overload
427
445
  @staticmethod
428
446
  def from_aq(model: Model) -> str: ...
429
447
  @overload
430
448
  @staticmethod
431
- def from_aq(model: Model, *, filepath: Path) -> None:
449
+ def from_aq(model: Model, *, filepath: Path) -> None: ...
450
+ @staticmethod
451
+ def from_aq(model: Model, *, filepath: Path | None = ...) -> None:
432
452
  """
433
453
  Convert a symbolic model to an LP file representation.
434
454
 
@@ -449,16 +469,16 @@ class LpTranslator:
449
469
  TranslationError
450
470
  If the translation fails for some reason.
451
471
  """
472
+ ...
452
473
 
453
474
  class IbmTranslator:
454
- """
455
- Utility class for converting between an IBM solution and our solution format.
475
+ """Utility class for converting between an IBM solution and our solution format.
456
476
 
457
477
  `IbmTranslator` provides methods to:
458
478
  - Convert an IBM-style solution into our solution `Solution`.
459
479
 
460
- The conversions are especially required when interacting with external ibm solvers/samplers or
461
- libraries that operate on ibm-based problem-solving/sampling.
480
+ The conversions are especially required when interacting with external ibm
481
+ solvers/samplers oe libraries that operate on ibm-based problem-solving/sampling.
462
482
 
463
483
  Examples
464
484
  --------
@@ -524,8 +544,8 @@ class IbmTranslator:
524
544
  NoActiveEnvironmentFoundError
525
545
  If no environment is passed to the method or available from the context.
526
546
  SolutionTranslationError
527
- Generally if the solution translation fails. Might be specified by one of the
528
- two following errors.
547
+ Generally if the solution translation fails. Might be specified by one of
548
+ the two following errors.
529
549
  SampleIncorrectLengthError
530
550
  If a solution's sample has a different number of variables than the model
531
551
  environment passed to the translator.
@@ -533,16 +553,17 @@ class IbmTranslator:
533
553
  If the result's variable types are incompatible with the model environment's
534
554
  variable types.
535
555
  """
556
+ ...
536
557
 
537
558
  class DwaveTranslator:
538
- """
539
- Utility class for converting between a DWAVE solution and our solution format.
559
+ """Utility class for converting between a DWAVE solution and our solution format.
540
560
 
541
561
  `DWaveSolutionTranslator` provides methods to:
542
562
  - Convert a dimod-style solution into our solution `Solution`.
543
563
 
544
564
  The conversions are especially required when interacting with external dwave/dimod
545
- solvers/samplers or libraries that operate on dwave/dimod-based problem-solving/sampling.
565
+ solvers/samplers or libraries that operate on dwave/dimod-based problem-solving/
566
+ sampling.
546
567
 
547
568
  Examples
548
569
  --------
@@ -590,8 +611,8 @@ class DwaveTranslator:
590
611
  NoActiveEnvironmentFoundError
591
612
  If no environment is passed to the method or available from the context.
592
613
  SolutionTranslationError
593
- Generally if the solution translation fails. Might be specified by one of the
594
- two following errors.
614
+ Generally if the solution translation fails. Might be specified by one of
615
+ the two following errors.
595
616
  SampleIncorrectLengthError
596
617
  If a solution's sample has a different number of variables than the model
597
618
  environment passed to the translator.
@@ -599,9 +620,11 @@ class DwaveTranslator:
599
620
  If the result's variable types are incompatible with the model environment's
600
621
  variable types.
601
622
  """
623
+ ...
602
624
 
603
625
  class CqmTranslator:
604
- """
626
+ """CQM to AQM translator.
627
+
605
628
  Utility class for converting between dimod.BinaryQuadraticModel (CQM) and symbolic
606
629
  models.
607
630
 
@@ -616,7 +639,7 @@ class CqmTranslator:
616
639
  --------
617
640
  >>> import dimod
618
641
  >>> import numpy as np
619
- >>> from luna_quantum import CqmTranslator, Vtype
642
+ >>> from luna_quantum.translator import CqmTranslator, Vtype
620
643
  >>> bqm = dimod.generators.gnm_random_bqm(5, 10, "BINARY")
621
644
 
622
645
  Create a model from a matrix:
@@ -650,6 +673,8 @@ class CqmTranslator:
650
673
  TranslationError
651
674
  If the translation fails for some reason.
652
675
  """
676
+ ...
677
+
653
678
  @staticmethod
654
679
  def from_aq(model: Model) -> ConstrainedQuadraticModel:
655
680
  """
@@ -671,9 +696,11 @@ class CqmTranslator:
671
696
  TranslationError
672
697
  If the translation fails for some reason.
673
698
  """
699
+ ...
674
700
 
675
701
  class BqmTranslator:
676
- """
702
+ """BQM to AQM translator.
703
+
677
704
  Utility class for converting between dimod.BinaryQuadraticModel (BQM) and symbolic
678
705
  models.
679
706
 
@@ -688,7 +715,7 @@ class BqmTranslator:
688
715
  --------
689
716
  >>> import dimod
690
717
  >>> import numpy as np
691
- >>> from luna_quantum import BqmTranslator, Vtype
718
+ >>> from luna_quantum.translator import BqmTranslator, Vtype
692
719
  >>> bqm = dimod.generators.gnm_random_bqm(5, 10, "BINARY")
693
720
 
694
721
  Create a model from a matrix:
@@ -705,7 +732,9 @@ class BqmTranslator:
705
732
  def to_aq(bqm: BinaryQuadraticModel) -> Model: ...
706
733
  @overload
707
734
  @staticmethod
708
- def to_aq(bqm: BinaryQuadraticModel, *, name: str) -> Model:
735
+ def to_aq(bqm: BinaryQuadraticModel, *, name: str) -> Model: ...
736
+ @staticmethod
737
+ def to_aq(bqm: BinaryQuadraticModel, *, name: str | None = ...) -> Model:
709
738
  """
710
739
  Convert a BQM into a symbolic `Model`.
711
740
 
@@ -721,6 +750,8 @@ class BqmTranslator:
721
750
  Model
722
751
  A symbolic model representing the given BQM.
723
752
  """
753
+ ...
754
+
724
755
  @staticmethod
725
756
  def from_aq(model: Model) -> BinaryQuadraticModel:
726
757
  """
@@ -752,6 +783,7 @@ class BqmTranslator:
752
783
  If the model contains different vtypes or vtypes other than binary and
753
784
  spin.
754
785
  """
786
+ ...
755
787
 
756
788
  class AwsTranslator:
757
789
  """
@@ -760,8 +792,8 @@ class AwsTranslator:
760
792
  `AwsTranslator` provides methods to:
761
793
  - Convert an AWS-style result into our solution `Solution`.
762
794
 
763
- The conversions are especially required when interacting with external aws solvers/samplers or
764
- libraries that operate on aws-based problem-solving/sampling.
795
+ The conversions are especially required when interacting with external aws
796
+ solvers/samplers or libraries that operate on aws-based problem-solving/sampling.
765
797
 
766
798
  Examples
767
799
  --------
@@ -808,8 +840,8 @@ class AwsTranslator:
808
840
  NoActiveEnvironmentFoundError
809
841
  If no environment is passed to the method or available from the context.
810
842
  SolutionTranslationError
811
- Generally if the solution translation fails. Might be specified by one of the
812
- two following errors.
843
+ Generally if the solution translation fails. Might be specified by one of
844
+ the two following errors.
813
845
  SampleIncorrectLengthError
814
846
  If a solution's sample has a different number of variables than the model
815
847
  environment passed to the translator.
@@ -817,6 +849,7 @@ class AwsTranslator:
817
849
  If the result's variable types are incompatible with the model environment's
818
850
  variable types.
819
851
  """
852
+ ...
820
853
 
821
854
  __all__ = [
822
855
  "AwsTranslator",
luna_quantum/utils.py CHANGED
@@ -1,17 +1,37 @@
1
+ """Utility module containing convenience functions."""
2
+
1
3
  from collections.abc import Iterable
2
4
 
3
5
  from ._core import Expression, Variable
4
6
 
5
7
 
8
+ class InvalidStartTypeError(TypeError):
9
+ """To be raised when an invalid start type is specified in quicksum."""
10
+
11
+ def __init__(self, actual: type) -> None:
12
+ super().__init__(f"start must be of type `Expression`, is '{actual}'")
13
+
14
+
15
+ class StartCannotBeInferredError(TypeError):
16
+ """To be raised when the start value in the quicksum cannot be inferred."""
17
+
18
+ def __init__(self) -> None:
19
+ super().__init__(
20
+ "iterable must contain at least one Expression or Variable, "
21
+ "or 'start' needs to be set."
22
+ )
23
+
24
+
6
25
  def quicksum(
7
26
  iterable: Iterable[Expression | Variable | int | float],
8
27
  /,
9
28
  start: Expression | None = None,
10
29
  ) -> Expression:
11
- """
12
- Create an Expression based on an iterable of Expression, Variable, int or float elements.
13
- Note that either the `iterable` must contain at least one `Expression` or `Variable` or
14
- the start parameter is set.
30
+ """Sum over an Iterable of Expression, Variable, int or float values.
31
+
32
+ Create an Expression based on an iterable of Expression, Variable, int or float
33
+ elements. Note that either the `iterable` must contain at least one `Expression`
34
+ or `Variable` or the start parameter is set.
15
35
 
16
36
  Parameters
17
37
  ----------
@@ -27,24 +47,22 @@ def quicksum(
27
47
 
28
48
  Raises
29
49
  ------
30
- TypeError
50
+ TypeError (InvalidStartTypeError | StartCannotBeInferredError)
31
51
  If the `iterable` does not contain any Expression or Variable.
32
52
  If the `start` is not of type Expression.
33
53
  """
34
54
  items = list(iterable)
35
55
  if start is None:
36
56
  for item in items:
37
- if isinstance(item, Expression) or isinstance(item, Variable):
38
- start = Expression(env=item._environment) # type: ignore
57
+ if isinstance(item, Expression | Variable):
58
+ start = Expression(env=item._environment) # noqa: SLF001
39
59
  break
40
60
 
41
61
  if start is None:
42
- raise TypeError(
43
- "iterable must contain at least one Expression or Variable,or 'start' needs to be set."
44
- )
62
+ raise StartCannotBeInferredError
45
63
 
46
64
  if not isinstance(start, Expression):
47
- raise TypeError("start must be of type `Expression`")
65
+ raise InvalidStartTypeError(type(start))
48
66
 
49
67
  _start: Expression = start
50
68
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luna-quantum
3
- Version: 1.0.0
3
+ Version: 1.0.1rc10
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: License :: OSI Approved :: Apache Software License
6
6
  Classifier: Operating System :: OS Independent
@@ -10,15 +10,13 @@ Requires-Dist: numpy>=1
10
10
  Requires-Dist: pydantic[email]>=2.11.3,<3
11
11
  Requires-Dist: python-dateutil>=2.9.0,<3
12
12
  Requires-Dist: rich>=14.0.0
13
- Requires-Dist: networkx>=3.4.2,<4 ; extra == 'examples'
14
- Provides-Extra: examples
15
13
  License-File: LICENSE
16
14
  License-File: NOTICE
17
15
  Summary: Python SDK for Aqarios' Luna Platform
18
16
  Keywords: aqarios,luna,quantum computing,quantum optimization,optimization,sdk
19
17
  Author-email: Aqarios <pypi@aqarios.com>
20
18
  License: Apache-2.0
21
- Requires-Python: >=3.11.0, <4
19
+ Requires-Python: >=3.11.0, <3.14
22
20
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
21
  Project-URL: Homepage, https://aqarios.com/
24
22
  Project-URL: Documentation, https://docs.aqarios.com/