luna-quantum 1.0.8rc2__cp314-cp314-macosx_11_0_arm64.whl → 1.0.8rc3__cp314-cp314-macosx_11_0_arm64.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.

luna_quantum/__init__.py CHANGED
@@ -29,12 +29,14 @@ from ._core import (
29
29
  Comparator,
30
30
  Constant,
31
31
  Constraint,
32
- Constraints,
32
+ ConstraintCollection,
33
+ ConstraintType,
33
34
  Environment,
34
35
  Expression,
35
36
  ExpressionIterator,
36
37
  HigherOrder,
37
38
  Linear,
39
+ ModelSpecs,
38
40
  Quadratic,
39
41
  Result,
40
42
  ResultIterator,
@@ -56,8 +58,17 @@ from ._core import (
56
58
  translator,
57
59
  utils,
58
60
  )
61
+ from ._utility import deprecated
59
62
  from .utils import quicksum
60
63
 
64
+
65
+ @deprecated(
66
+ "`Constraints` class name is deprecated and will be removed, "
67
+ "use `ConstraintCollection` instead."
68
+ )
69
+ class Constraints(ConstraintCollection): ... # noqa: D101 # comes from aq-models
70
+
71
+
61
72
  __version__ = __luna_quantum_version__
62
73
  UseCaseFactory.set_model_fetch_class(ModelFetchMetadataUseCase)
63
74
  UseCaseFactory.set_model_delete_class(ModelDeleteUseCase)
@@ -78,6 +89,8 @@ __all__ = [
78
89
  "Comparator",
79
90
  "Constant",
80
91
  "Constraint",
92
+ "ConstraintCollection",
93
+ "ConstraintType",
81
94
  "Constraints",
82
95
  "DefaultToken",
83
96
  "Environment",
@@ -90,6 +103,7 @@ __all__ = [
90
103
  "LunaSolve",
91
104
  "LunaSolveClientFactory",
92
105
  "Model",
106
+ "ModelSpecs",
93
107
  "Quadratic",
94
108
  "Result",
95
109
  "ResultIterator",
luna_quantum/__init__.pyi CHANGED
@@ -1,14 +1,17 @@
1
+ from warnings import deprecated
1
2
  from ._core import (
2
3
  Bounds,
3
4
  Comparator,
4
5
  Constant,
5
6
  Constraint,
6
- Constraints,
7
+ ConstraintCollection,
8
+ ConstraintType,
7
9
  Environment,
8
10
  Expression,
9
11
  ExpressionIterator,
10
12
  HigherOrder,
11
13
  Linear,
14
+ ModelSpecs,
12
15
  Quadratic,
13
16
  Result,
14
17
  ResultIterator,
@@ -23,6 +26,7 @@ from ._core import (
23
26
  Timing,
24
27
  Unbounded,
25
28
  Variable,
29
+ ValueSource,
26
30
  Vtype,
27
31
  errors,
28
32
  transformations,
@@ -39,12 +43,19 @@ from luna_quantum.solve.parameters import algorithms, backends, constants
39
43
  from luna_quantum.util.debug_info import debug_info
40
44
  from luna_quantum.util.log_utils import Logging
41
45
 
46
+ @deprecated(
47
+ "`Constraints` class name is deprecated and will be removed, use `ConstraintCollection` instead."
48
+ )
49
+ class Constraints(ConstraintCollection): ...
50
+
42
51
  __version__ = __luna_quantum_version__
43
52
  __all__ = [
44
53
  "Bounds",
45
54
  "Comparator",
46
55
  "Constant",
47
56
  "Constraint",
57
+ "ConstraintCollection",
58
+ "ConstraintType",
48
59
  "Constraints",
49
60
  "DefaultToken",
50
61
  "Environment",
@@ -56,6 +67,7 @@ __all__ = [
56
67
  "LunaQ",
57
68
  "LunaSolve",
58
69
  "Model",
70
+ "ModelSpecs",
59
71
  "Quadratic",
60
72
  "Result",
61
73
  "ResultIterator",
@@ -69,6 +81,7 @@ __all__ = [
69
81
  "Timer",
70
82
  "Timing",
71
83
  "Unbounded",
84
+ "ValueSource",
72
85
  "Variable",
73
86
  "Vtype",
74
87
  "__version__",
Binary file
luna_quantum/_core.pyi CHANGED
@@ -5,10 +5,13 @@ from types import TracebackType
5
5
  from typing import Literal, Self, overload
6
6
  from numpy.typing import NDArray
7
7
  from . import errors, transformations, translator, utils
8
+ from ._utility import deprecated
8
9
  from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
9
10
  from luna_quantum.solve.domain.model_metadata import ModelMetadata
10
11
  from luna_quantum.solve.domain.solve_job import SolveJob
11
12
 
13
+ __version__ = ...
14
+
12
15
  class Vtype(Enum):
13
16
  """
14
17
  Enumeration of variable types supported by the optimization system.
@@ -963,6 +966,11 @@ class Solution:
963
966
  """Get the solver / algorithm runtime."""
964
967
  ...
965
968
 
969
+ @runtime.setter
970
+ def runtime(self, /, timing: Timing) -> None:
971
+ """Get the solver / algorithm runtime."""
972
+ ...
973
+
966
974
  @property
967
975
  def sense(self, /) -> Sense:
968
976
  """Get the optimization sense."""
@@ -1245,39 +1253,6 @@ class Solution:
1245
1253
  counts: int = ...,
1246
1254
  sense: Sense = ...,
1247
1255
  ) -> Solution: ...
1248
- @overload
1249
- @staticmethod
1250
- def from_dict(
1251
- data: dict[Variable, int | float],
1252
- *,
1253
- env: Environment = ...,
1254
- model: Model = ...,
1255
- timing: Timing = ...,
1256
- counts: int = ...,
1257
- sense: Sense = ...,
1258
- ) -> Solution: ...
1259
- @overload
1260
- @staticmethod
1261
- def from_dict(
1262
- data: dict[str, int | float],
1263
- *,
1264
- env: Environment = ...,
1265
- model: Model = ...,
1266
- timing: Timing = ...,
1267
- counts: int = ...,
1268
- sense: Sense = ...,
1269
- ) -> Solution: ...
1270
- @overload
1271
- @staticmethod
1272
- def from_dict(
1273
- data: dict[Variable | str, int | float],
1274
- *,
1275
- env: Environment = ...,
1276
- model: Model = ...,
1277
- timing: Timing = ...,
1278
- counts: int = ...,
1279
- sense: Sense = ...,
1280
- ) -> Solution: ...
1281
1256
  @staticmethod
1282
1257
  def from_dict(
1283
1258
  data: dict[Variable | str, int | float],
@@ -1400,39 +1375,6 @@ class Solution:
1400
1375
  counts: list[int] = ...,
1401
1376
  sense: Sense = ...,
1402
1377
  ) -> Solution: ...
1403
- @overload
1404
- @staticmethod
1405
- def from_dicts(
1406
- data: list[dict[Variable, int | float]],
1407
- *,
1408
- env: Environment = ...,
1409
- model: Model = ...,
1410
- timing: Timing = ...,
1411
- counts: list[int] = ...,
1412
- sense: Sense = ...,
1413
- ) -> Solution: ...
1414
- @overload
1415
- @staticmethod
1416
- def from_dicts(
1417
- data: list[dict[str, int | float]],
1418
- *,
1419
- env: Environment = ...,
1420
- model: Model = ...,
1421
- timing: Timing = ...,
1422
- counts: list[int] = ...,
1423
- sense: Sense = ...,
1424
- ) -> Solution: ...
1425
- @overload
1426
- @staticmethod
1427
- def from_dicts(
1428
- data: list[dict[Variable | str, int | float]],
1429
- *,
1430
- env: Environment = ...,
1431
- model: Model = ...,
1432
- timing: Timing = ...,
1433
- counts: list[int] = ...,
1434
- sense: Sense = ...,
1435
- ) -> Solution: ...
1436
1378
  @staticmethod
1437
1379
  def from_dicts(
1438
1380
  data: list[dict[Variable | str, int | float]],
@@ -2066,13 +2008,124 @@ class Sense(Enum):
2066
2008
  Max = ...
2067
2009
  """Indicate the objective function to be maximized."""
2068
2010
 
2011
+ class ConstraintType(Enum):
2012
+ """
2013
+ Enumeration of constraint types supported by the optimization system.
2014
+
2015
+ This enum defines the type of constraint used within a model.
2016
+ """
2017
+
2018
+ Unconstrained = ...
2019
+ """The model contains no constraints, i.e., is unconstrained."""
2020
+ Equality = ...
2021
+ """The model contains equality constraints (`Comparator.Eq`)."""
2022
+ Inequality = ...
2023
+ """The model contains inequality constraints (`Comparator.Le`, `Comparator.Ge`).
2024
+
2025
+ implicitly includes the `ConstraintType.LessEqual` and `ConstraintType.GreaterEqual`
2026
+ options.
2027
+ """
2028
+ LessEqual = ...
2029
+ """The model contains less-equal-inequality constraints (`Comparator.Le`)."""
2030
+ GreaterEqual = ...
2031
+ """The model contains greater-equal-inequality constraints (`Comparator.Ge`)."""
2032
+
2033
+ class ModelSpecs:
2034
+ """A class containing sepcifications of a model."""
2035
+
2036
+ def __init__(
2037
+ self,
2038
+ /,
2039
+ *,
2040
+ sense: (Sense | None) = ...,
2041
+ vtypes: (list[Vtype] | None) = ...,
2042
+ constraints: (list[ConstraintType] | None) = ...,
2043
+ max_degree: (int | None) = ...,
2044
+ max_constraint_degree: (int | None) = ...,
2045
+ max_num_variables: (int | None) = ...,
2046
+ ) -> None:
2047
+ """Create a ModelSpec instance.
2048
+
2049
+ Parameters
2050
+ ----------
2051
+ sense: Sense | None
2052
+ The exepected Sense of a model, default None.
2053
+ vtypes: list[Vtype] | None
2054
+ The exepected vtypes in a model, default None.
2055
+ constraints: list[ConstraintType] | None = ...,
2056
+ The exepected constraint types in a model, default None.
2057
+ max_degree: int | None
2058
+ The exepected maximum degree of the model's objective function,
2059
+ default None.
2060
+ max_constraint_degree: int | None
2061
+ The exepected maximum degree of the model's constraints, default None.
2062
+ max_num_variables: int | None
2063
+ The exepected maximum number of the variables in the model, default None.
2064
+ """
2065
+ ...
2066
+
2067
+ @property
2068
+ def sense(self) -> Sense | None:
2069
+ """The sense specification, can be `None` if no sense spec is available."""
2070
+ ...
2071
+
2072
+ @property
2073
+ def max_degree(self) -> int | None:
2074
+ """The specification for the max degree of the objective function.
2075
+
2076
+ Can be `None` if no max_degree spec is available.
2077
+ """
2078
+ ...
2079
+
2080
+ @property
2081
+ def max_constraint_degree(self) -> int | None:
2082
+ """The specification for the max degree of all constraints.
2083
+
2084
+ Can be `None` if no max_constraint_degree spec is available.
2085
+ """
2086
+ ...
2087
+
2088
+ @property
2089
+ def max_num_variables(self) -> int | None:
2090
+ """The specification for the max number of variables in the model.
2091
+
2092
+ Can be `None` if no max_num_variables spec is available.
2093
+ """
2094
+ ...
2095
+
2096
+ @property
2097
+ def vtypes(self) -> list[Vtype] | None:
2098
+ """The vtypes specification, can be `None` if no vtypes spec is available."""
2099
+ ...
2100
+
2101
+ @property
2102
+ def constraints(self) -> list[ConstraintType] | None:
2103
+ """
2104
+ The constraints specification.
2105
+
2106
+ Can be `None` if no constraints spec is available.
2107
+ """
2108
+ ...
2109
+
2110
+ def satisfies(self, other: ModelSpecs) -> bool:
2111
+ """Check if `self` satisfies the model specs given in `other`.
2112
+
2113
+ Parameters
2114
+ ----------
2115
+ other : ModelSpecs
2116
+ The model specifications `self` should satisfy.
2117
+ """
2118
+ ...
2119
+
2120
+ def __str__(self, /) -> str: ...
2121
+
2069
2122
  class Model:
2070
2123
  """
2071
2124
  A symbolic optimization model consisting of an objective and constraints.
2072
2125
 
2073
2126
  The `Model` class represents a structured symbolic optimization problem. It
2074
- combines a scalar objective `Expression`, a collection of `Constraints`, and
2075
- a shared `Environment` that scopes all variables used in the model.
2127
+ combines a scalar objective `Expression`, a collection of `ConstraintCollection`,
2128
+ and a shared `Environment` that scopes all variables used in the model.
2076
2129
 
2077
2130
  Models can be constructed explicitly by passing an environment, or implicitly
2078
2131
  by allowing the model to create its own private environment. If constructed
@@ -2338,12 +2391,12 @@ class Model:
2338
2391
  ...
2339
2392
 
2340
2393
  @property
2341
- def constraints(self, /) -> Constraints:
2394
+ def constraints(self, /) -> ConstraintCollection:
2342
2395
  """Access the set of constraints associated with the model."""
2343
2396
  ...
2344
2397
 
2345
2398
  @constraints.setter
2346
- def constraints(self, value: Constraints, /) -> None:
2399
+ def constraints(self, value: ConstraintCollection, /) -> None:
2347
2400
  """Replace the model's constraints with a new set."""
2348
2401
  ...
2349
2402
 
@@ -2466,7 +2519,7 @@ class Model:
2466
2519
  """
2467
2520
  ...
2468
2521
 
2469
- def violated_constraints(self, /, sample: Sample) -> Constraints:
2522
+ def violated_constraints(self, /, sample: Sample) -> ConstraintCollection:
2470
2523
  """
2471
2524
  Get all model constraints that are violated by the given sample.
2472
2525
 
@@ -2477,7 +2530,7 @@ class Model:
2477
2530
 
2478
2531
  Returns
2479
2532
  -------
2480
- Constraints
2533
+ ConstraintCollection
2481
2534
  The constraints violated by the given sample.
2482
2535
  """
2483
2536
  ...
@@ -2513,6 +2566,21 @@ class Model:
2513
2566
  If the environments of `self`, `target`, and `replacement`
2514
2567
  are not compatible.
2515
2568
  """
2569
+ ...
2570
+
2571
+ def get_specs(self) -> ModelSpecs:
2572
+ """Get this model's specs."""
2573
+ ...
2574
+
2575
+ def satisfies(self, specs: ModelSpecs) -> bool:
2576
+ """Check if the model satisfies the given specs.
2577
+
2578
+ Parameters
2579
+ ----------
2580
+ specs : ModelSpecs
2581
+ The sepcs this model's specs are compared to.
2582
+ """
2583
+ ...
2516
2584
 
2517
2585
  @overload
2518
2586
  def encode(self, /) -> bytes: ...
@@ -3934,30 +4002,46 @@ class Constraint:
3934
4002
  def __str__(self, /) -> str: ...
3935
4003
  def __repr__(self, /) -> str: ...
3936
4004
 
3937
- class Constraints:
4005
+ class ConstraintCollectionIterator:
4006
+ """
4007
+ Iterate over the name, constraint tuples of a constraint collection.
4008
+
4009
+ Examples
4010
+ --------
4011
+ >>> from luna_quantum import ConstraintCollection
4012
+ >>> coll: ConstraintCollection = ...
4013
+ for (name, constraint) in coll.items():
4014
+ ...
4015
+ """
4016
+
4017
+ def __next__(self) -> tuple[str, Constraint]: ...
4018
+ def __iter__(self) -> ConstraintCollectionIterator: ...
4019
+
4020
+ class ConstraintCollection:
3938
4021
  """
3939
4022
  A collection of symbolic constraints used to define a model.
3940
4023
 
3941
- The `Constraints` object serves as a container for individual `Constraint`
4024
+ The `ConstraintCollection` object serves as a container for individual `Constraint`
3942
4025
  instances. It supports adding constraints programmatically and exporting
3943
4026
  them for serialization.
3944
4027
 
3945
- Constraints are typically added using `add_constraint()` or the `+=` operator.
4028
+ ConstraintCollection are typically added using `add_constraint()`
4029
+ or the `+=` operator.
3946
4030
 
3947
4031
  Examples
3948
4032
  --------
3949
- >>> from luna_quantum import Constraints, Constraint, Environment, Variable
4033
+ >>> from luna_quantum import ConstraintCollection, Constraint, Environment, Variable
3950
4034
  >>> with Environment():
3951
4035
  ... x = Variable("x")
3952
4036
  ... c = Constraint(x + 1, 0.0, Comparator.Le)
3953
4037
 
3954
- >>> cs = Constraints()
4038
+ >>> cs = ConstraintCollection()
3955
4039
  >>> cs += x >= 1.0
3956
4040
 
3957
4041
  Serialization:
3958
4042
 
3959
4043
  >>> blob = cs.encode()
3960
- >>> expr = Constraints.decode(blob)
4044
+ >>> expr = ConstraintCollection.decode(blob)
3961
4045
 
3962
4046
  Notes
3963
4047
  -----
@@ -3985,6 +4069,10 @@ class Constraints:
3985
4069
  """
3986
4070
  ...
3987
4071
 
4072
+ def items(self, /) -> ConstraintCollectionIterator:
4073
+ """Iterate over all items (`(name, constraint)`) in the collection."""
4074
+ ...
4075
+
3988
4076
  @overload
3989
4077
  def encode(self, /) -> bytes: ...
3990
4078
  @overload
@@ -4082,7 +4170,7 @@ class Constraints:
4082
4170
 
4083
4171
  Returns
4084
4172
  -------
4085
- Constraints
4173
+ ConstraintCollection
4086
4174
  The updated collection.
4087
4175
 
4088
4176
  Raises
@@ -4094,6 +4182,9 @@ class Constraints:
4094
4182
 
4095
4183
  @overload
4096
4184
  def get(self, item: str, /) -> Constraint: ...
4185
+ @deprecated(
4186
+ "Constraint access using int will be removed, use name (str) based indexing instead."
4187
+ )
4097
4188
  @overload
4098
4189
  def get(self, item: int, /) -> Constraint: ...
4099
4190
  def get(self, item: (int | str), /) -> Constraint:
@@ -4102,22 +4193,31 @@ class Constraints:
4102
4193
 
4103
4194
  @overload
4104
4195
  def remove(self, item: str, /) -> Constraint: ...
4196
+ @deprecated(
4197
+ "Constraint access using int will be removed, use name (str) based indexing instead."
4198
+ )
4105
4199
  @overload
4106
4200
  def remove(self, item: int, /) -> Constraint: ...
4107
4201
  def remove(self, item: (int | str), /) -> Constraint:
4108
4202
  """Remove a constraint for its name or index."""
4109
4203
  ...
4110
4204
 
4111
- def __eq__(self, other: Constraints, /) -> bool: ...
4205
+ def __eq__(self, other: ConstraintCollection, /) -> bool: ...
4112
4206
  def __str__(self, /) -> str: ...
4113
4207
  def __repr__(self, /) -> str: ...
4114
4208
  @overload
4115
4209
  def __getitem__(self, item: str, /) -> Constraint: ...
4210
+ @deprecated(
4211
+ "Constraint access using int will be removed, use name (str) based indexing instead."
4212
+ )
4116
4213
  @overload
4117
4214
  def __getitem__(self, item: int, /) -> Constraint: ...
4118
4215
  def __getitem__(self, item: (int | str), /) -> Constraint: ...
4119
4216
  @overload
4120
4217
  def __setitem__(self, item: str, content: Constraint, /) -> None: ...
4218
+ @deprecated(
4219
+ "Constraint access using int will be removed, use name (str) based indexing instead."
4220
+ )
4121
4221
  @overload
4122
4222
  def __setitem__(self, item: int, content: Constraint, /) -> None: ...
4123
4223
  def __setitem__(self, item: (int | str), content: Constraint, /) -> None: ...
@@ -4128,18 +4228,19 @@ class Constraints:
4128
4228
  Returns
4129
4229
  -------
4130
4230
  int
4131
- The number of constraints associated with this `Constraints` object.
4231
+ The number of constraints associated with this `ConstraintCollection`
4232
+ object.
4132
4233
  """
4133
4234
  ...
4134
4235
 
4135
4236
  def __iter__(self, /) -> Iterator[Constraint]: ...
4136
- def equal_contents(self, other: Constraints, /) -> bool:
4237
+ def equal_contents(self, other: ConstraintCollection, /) -> bool:
4137
4238
  """
4138
4239
  Check whether this constraints has equal contents as `other`.
4139
4240
 
4140
4241
  Parameters
4141
4242
  ----------
4142
- other : Constraints
4243
+ other : ConstraintCollection
4143
4244
 
4144
4245
  Returns
4145
4246
  -------
@@ -4158,7 +4259,7 @@ __all__ = [
4158
4259
  "Bounds",
4159
4260
  "Comparator",
4160
4261
  "Constraint",
4161
- "Constraints",
4262
+ "ConstraintCollection",
4162
4263
  "Environment",
4163
4264
  "Expression",
4164
4265
  "Model",
@@ -0,0 +1,148 @@
1
+ """Utility module for internals."""
2
+
3
+ import sys
4
+
5
+ if sys.version_info < (3, 13):
6
+ from warnings import warn
7
+
8
+ class DeprecationWarning(Warning): ... # noqa: A001
9
+
10
+ class deprecated: # noqa: N801
11
+ """Indicate that a class, function or overload is deprecated.
12
+
13
+ When this decorator is applied to an object, the type checker
14
+ will generate a diagnostic on usage of the deprecated object.
15
+
16
+ Usage:
17
+
18
+ @deprecated("Use B instead")
19
+ class A:
20
+ pass
21
+
22
+ @deprecated("Use g instead")
23
+ def f():
24
+ pass
25
+
26
+ @overload
27
+ @deprecated("int support is deprecated")
28
+ def g(x: int) -> int: ...
29
+ @overload
30
+ def g(x: str) -> int: ...
31
+
32
+ The warning specified by *category* will be emitted at runtime
33
+ on use of deprecated objects. For functions, that happens on calls;
34
+ for classes, on instantiation and on creation of subclasses.
35
+ If the *category* is ``None``, no warning is emitted at runtime.
36
+ The *stacklevel* determines where the
37
+ warning is emitted. If it is ``1`` (the default), the warning
38
+ is emitted at the direct caller of the deprecated object; if it
39
+ is higher, it is emitted further up the stack.
40
+ Static type checker behavior is not affected by the *category*
41
+ and *stacklevel* arguments.
42
+
43
+ The deprecation message passed to the decorator is saved in the
44
+ ``__deprecated__`` attribute on the decorated object.
45
+ If applied to an overload, the decorator
46
+ must be after the ``@overload`` decorator for the attribute to
47
+ exist on the overload as returned by ``get_overloads()``.
48
+
49
+ See PEP 702 for details.
50
+
51
+ """
52
+
53
+ def __init__(
54
+ self,
55
+ message: str,
56
+ /,
57
+ *,
58
+ category: type[Warning] | None = DeprecationWarning, # noqa: PYI011,RUF100
59
+ stacklevel: int = 1,
60
+ ) -> None:
61
+ if not isinstance(message, str):
62
+ raise TypeError( # noqa: TRY003
63
+ f"Expected an object of type str for 'message', not {type(message).__name__!r}" # noqa: E501
64
+ )
65
+ self.message = message
66
+ self.category = category
67
+ self.stacklevel = stacklevel
68
+
69
+ def __call__(self, arg, /): # noqa: C901,ANN001,ANN204
70
+ # Make sure the inner functions created below don't
71
+ # retain a reference to self.
72
+ msg = self.message
73
+ category = self.category
74
+ stacklevel = self.stacklevel
75
+ if category is None:
76
+ arg.__deprecated__ = msg
77
+ return arg
78
+ elif isinstance(arg, type): # noqa: RET505
79
+ import functools # noqa: PLC0415
80
+ from types import MethodType # noqa: PLC0415
81
+
82
+ original_new = arg.__new__
83
+
84
+ @functools.wraps(original_new)
85
+ def __new__(cls, /, *args, **kwargs): # noqa: N807,ANN001,ANN202,ANN003,ANN002
86
+ if cls is arg:
87
+ warn(msg, category=category, stacklevel=stacklevel + 1)
88
+ if original_new is not object.__new__:
89
+ return original_new(cls, *args, **kwargs)
90
+ # Mirrors a similar check in object.__new__.
91
+ elif cls.__init__ is object.__init__ and (args or kwargs): # noqa: RET505
92
+ raise TypeError(f"{cls.__name__}() takes no arguments") # noqa: TRY003
93
+ else:
94
+ return original_new(cls)
95
+
96
+ arg.__new__ = staticmethod(__new__)
97
+
98
+ original_init_subclass = arg.__init_subclass__
99
+ # We need slightly different behavior if __init_subclass__
100
+ # is a bound method (likely if it was implemented in Python)
101
+ if isinstance(original_init_subclass, MethodType):
102
+ original_init_subclass = original_init_subclass.__func__
103
+
104
+ @functools.wraps(original_init_subclass)
105
+ def __init_subclass__(*args, **kwargs): # noqa: ANN002,ANN202,ANN003,N807
106
+ warn(msg, category=category, stacklevel=stacklevel + 1)
107
+ return original_init_subclass(*args, **kwargs)
108
+
109
+ arg.__init_subclass__ = classmethod(__init_subclass__)
110
+ # Or otherwise, which likely means it's a builtin such as
111
+ # object's implementation of __init_subclass__.
112
+ else:
113
+
114
+ @functools.wraps(original_init_subclass)
115
+ def __init_subclass__(*args, **kwargs): # noqa: ANN202,ANN002,ANN003,N807
116
+ warn(msg, category=category, stacklevel=stacklevel + 1)
117
+ return original_init_subclass(*args, **kwargs)
118
+
119
+ arg.__init_subclass__ = __init_subclass__
120
+
121
+ arg.__deprecated__ = __new__.__deprecated__ = msg
122
+ __init_subclass__.__deprecated__ = msg
123
+ return arg
124
+ elif callable(arg):
125
+ import functools # noqa: PLC0415
126
+ import inspect # noqa: PLC0415
127
+
128
+ @functools.wraps(arg)
129
+ def wrapper(*args, **kwargs): # noqa: ANN002,ANN003,ANN202
130
+ warn(msg, category=category, stacklevel=stacklevel + 1)
131
+ return arg(*args, **kwargs)
132
+
133
+ if inspect.iscoroutinefunction(arg):
134
+ wrapper = inspect.markcoroutinefunction(wrapper)
135
+
136
+ arg.__deprecated__ = wrapper.__deprecated__ = msg
137
+ return wrapper
138
+ else:
139
+ raise TypeError( # noqa: TRY003
140
+ "@deprecated decorator with non-None category must be applied to "
141
+ f"a class or callable, not {arg!r}"
142
+ )
143
+
144
+ else:
145
+ from warnings import deprecated
146
+
147
+
148
+ __all__ = ["deprecated"]
@@ -0,0 +1,20 @@
1
+ import sys
2
+
3
+ if sys.version_info < (3, 13): # noqa: PYI066
4
+ class DeprecationWarning(Warning): ... # noqa: A001
5
+
6
+ class deprecated: # noqa: N801
7
+ def __init__(
8
+ self,
9
+ message: str,
10
+ /,
11
+ *,
12
+ category: type[Warning] | None = ...,
13
+ stacklevel: int = 1,
14
+ ) -> None: ...
15
+ def __call__(self, arg, /): ... # noqa: ANN001,ANN204
16
+
17
+ else:
18
+ from warnings import deprecated
19
+
20
+ __all__ = ["deprecated"]
@@ -0,0 +1,9 @@
1
+ from luna_quantum.client.schemas.enums.call_style import CallStyle
2
+ from luna_quantum.exceptions.base_luna_quantum_error import BaseLunaQuantumError
3
+
4
+
5
+ class LunaQuantumCallStyleError(BaseLunaQuantumError):
6
+ """Luna Quantum call style error."""
7
+
8
+ def __init__(self, call_style: CallStyle) -> None:
9
+ super().__init__(f"The call style '{call_style}' is not supported.")
@@ -2,6 +2,9 @@ from luna_quantum._core import Solution
2
2
  from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
3
3
  from luna_quantum.client.schemas.enums.call_style import CallStyle
4
4
  from luna_quantum.client.schemas.enums.status import StatusEnum
5
+ from luna_quantum.exceptions.luna_quantum_call_type_error import (
6
+ LunaQuantumCallStyleError,
7
+ )
5
8
  from luna_quantum.solve.domain.solve_job import SolveJob
6
9
  from luna_quantum.solve.interfaces.usecases.solve_job_get_result_usecase_i import (
7
10
  ISolveJobGetResultUseCase,
@@ -61,19 +64,26 @@ class SolveJobGetResultUseCase(ISolveJobGetResultUseCase):
61
64
  The solution for the given solve job if successfully processed, otherwise
62
65
  None.
63
66
  """
64
- if call_style is CallStyle.ACTIVE_WAITING:
65
- final_states = StatusEnum.CANCELED, StatusEnum.DONE, StatusEnum.FAILED
67
+ match call_style:
68
+ case CallStyle.ACTIVE_WAITING:
69
+ final_states = StatusEnum.CANCELED, StatusEnum.DONE, StatusEnum.FAILED
66
70
 
67
- ActiveWaiting.run(
68
- loop_check=lambda: solve_job.get_status(
69
- client=self.client, status_source="remote"
71
+ ActiveWaiting.run(
72
+ loop_check=lambda: solve_job.get_status(
73
+ client=self.client, status_source="remote"
74
+ )
75
+ not in final_states,
76
+ loop_call=None,
77
+ sleep_time_max=sleep_time_max,
78
+ sleep_time_increment=sleep_time_increment,
79
+ sleep_time_initial=sleep_time_initial,
70
80
  )
71
- not in final_states,
72
- loop_call=None,
73
- sleep_time_max=sleep_time_max,
74
- sleep_time_increment=sleep_time_increment,
75
- sleep_time_initial=sleep_time_initial,
76
- )
81
+ case CallStyle.SINGLE_FETCH:
82
+ solve_job.get_status(client=self.client, status_source="remote")
83
+
84
+ case _:
85
+ raise LunaQuantumCallStyleError(call_style)
86
+
77
87
  try:
78
88
  if solve_job.status == StatusEnum.CANCELED:
79
89
  self.logger.warning(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luna-quantum
3
- Version: 1.0.8rc2
3
+ Version: 1.0.8rc3
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: License :: OSI Approved :: Apache Software License
6
6
  Classifier: Operating System :: OS Independent
@@ -1,11 +1,13 @@
1
- luna_quantum-1.0.8rc2.dist-info/METADATA,sha256=-WHBusGtISjFAWvFLjd1yZBn5rYKWnB9TP_5Ku9vE6E,1585
2
- luna_quantum-1.0.8rc2.dist-info/WHEEL,sha256=1PvyiPvcJ94VD-5qzLXvCxiTKltkB9r5dXMQ1otw8Pg,104
3
- luna_quantum-1.0.8rc2.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
- luna_quantum-1.0.8rc2.dist-info/licenses/NOTICE,sha256=noPOS8eDj5XoyRO8ZrCxIOh5fSjk0RildIrrqxQlepY,588
5
- luna_quantum/__init__.py,sha256=8tQBzVi42I_1PuuACQW0wilcJWTt31ln5A4joNcPOSk,3259
6
- luna_quantum/__init__.pyi,sha256=1Joa1farT1Ey22yWYPMNPgQrGHIKL8bycrdPUgtQqw8,1661
7
- luna_quantum/_core.cpython-314-darwin.so,sha256=cRFW0nxGCnf86HUyNwRRc1Sfv6Cxoz6yf-H0tonGujA,5382912
8
- luna_quantum/_core.pyi,sha256=_nJmdvjPtibEZUD4FksyWR3J6ttAPoJhxrWZs_7Nz08,118028
1
+ luna_quantum-1.0.8rc3.dist-info/METADATA,sha256=IbDGJmp8yKMgd-8RGRMCIbCguLX2Yy5uizmb8XJcSog,1585
2
+ luna_quantum-1.0.8rc3.dist-info/WHEEL,sha256=1PvyiPvcJ94VD-5qzLXvCxiTKltkB9r5dXMQ1otw8Pg,104
3
+ luna_quantum-1.0.8rc3.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
4
+ luna_quantum-1.0.8rc3.dist-info/licenses/NOTICE,sha256=noPOS8eDj5XoyRO8ZrCxIOh5fSjk0RildIrrqxQlepY,588
5
+ luna_quantum/__init__.py,sha256=rcDpMhBOdDjteCh73EM1pKhxIBZOmDLQCzXGxXFKUGk,3614
6
+ luna_quantum/__init__.pyi,sha256=s2RfcxcRc0antqQnZvD7kKTwpbshkOM85F4d58dDKOE,2005
7
+ luna_quantum/_core.cpython-314-darwin.so,sha256=hqigG9XcpV9HIrVh4bXAXkBjOH1TvY1IEPSrCqUjG4M,5499472
8
+ luna_quantum/_core.pyi,sha256=ICnplN_bc5ScyMOSIW65YqkZzWQP_8BWLDquOGVemRY,121598
9
+ luna_quantum/_utility.py,sha256=6BbCJ2HDA92NtcUuVhnyUcG40-_FB1m21h-M3Z06v-8,6031
10
+ luna_quantum/_utility.pyi,sha256=DAZeMbhjaRf10adPv8QKt8GGOlaHjnfndDcbGmu-qUA,487
9
11
  luna_quantum/algorithms/__init__.py,sha256=IX9ZpzY3Do3mTgKqto5vAWwdYrZrM-RemYSf64yxefg,69
10
12
  luna_quantum/aqm_overwrites/__init__.py,sha256=rteObr5JHDnTnRime0Euq9Qy2iDIp6VMpFNHTGVNBe0,46
11
13
  luna_quantum/aqm_overwrites/model.py,sha256=La5mh-aS2LNLaQFp_B1EnhrKUXVRRmIqGnIvX66uc8Y,6099
@@ -86,6 +88,7 @@ luna_quantum/errors.py,sha256=yjeXB3i07LlTuuJ18IKgwsC5wmtJElN8cDwlg3JkcEs,1424
86
88
  luna_quantum/errors.pyi,sha256=PTVWbmHLrlNBMxz3wYni0nbqeMEGlzmIukMwgnF3bMo,9443
87
89
  luna_quantum/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
90
  luna_quantum/exceptions/base_luna_quantum_error.py,sha256=qC712QkF04FiY_qwQ5HlIYVhg5P6WzXJ_chJDVTpWXI,89
91
+ luna_quantum/exceptions/luna_quantum_call_type_error.py,sha256=mPXghYDBjSWGpodr8Y93hbq1RKfqJwGS42YYFkKLORk,379
89
92
  luna_quantum/exceptions/patch_class_field_exists_error.py,sha256=3TGKb-MNyjwntrJkbRaBKEvlsj68ROTwCltDt6Zg7Gg,398
90
93
  luna_quantum/factories/__init__.py,sha256=XT0vIcm65KVpYSLbqXdeoPd7yypSj36o1IC55CTaoj4,162
91
94
  luna_quantum/factories/luna_solve_client_factory.py,sha256=Y5vqDe8F0HMj3WluHxPl0KbB8KDWRTgWgbZ1igzt3hM,3284
@@ -247,7 +250,7 @@ luna_quantum/solve/usecases/solve_job_cancel_usecase.py,sha256=_FEUTfM4nq5iug3nT
247
250
  luna_quantum/solve/usecases/solve_job_create_usecase.py,sha256=IcKN2VWTGw3J3Wgnt5QolHYWjk__9tRi-KTf-pBmsT0,3934
248
251
  luna_quantum/solve/usecases/solve_job_delete_usecase.py,sha256=hUOLeFLU9NCggWMGuIJG7WYShQjP4H_iZJnPvBJgTpA,1128
249
252
  luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py,sha256=W-Z6Q7IuyodjZmFKEsJGaa9V2fnGMPWj9FRN9gEdPNc,1686
250
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py,sha256=dk6LSjInOfH5d7LlbUmawnqytKig_vFTCKTDK5KlDlI,3541
253
+ luna_quantum/solve/usecases/solve_job_get_result_usecase.py,sha256=OeujfR_SgYnO0lvgk1oqoGjsZfLN85ooSXZ9DazCQ74,3907
251
254
  luna_quantum/transformations.py,sha256=AZtGBaJ0PTWsr4mpONoJq5BpNOXPcM85CnWDhPgXx_I,902
252
255
  luna_quantum/transformations.pyi,sha256=wajxfV6QiD6R_7lUfk5kjAXp-ZHhOvLjtPqZCCX3UuU,10963
253
256
  luna_quantum/translator.py,sha256=xi5eiIRNv8ATz69GYpUY5kbEIUmQEtK6_dF5t2Mwpec,1134
@@ -261,4 +264,4 @@ luna_quantum/util/pretty_base.py,sha256=QUNFiyz5MPsMCZB-wv622oeZ1uLkZ-_0xepNbuzQ
261
264
  luna_quantum/util/pydantic_utils.py,sha256=nhl_SdLJVAizrtLVHvnbco84g8CdBVdVxN_jlXiv82w,1263
262
265
  luna_quantum/utils.py,sha256=pBOkGXNJXlOzxAwTJv8nCj32Q6WNeh3t6Ka3lmTgy9c,134
263
266
  luna_quantum/utils.pyi,sha256=yHHPluEJArUltZ2jJ9bPtTugj59E9TOTmYdyH35EHtU,1934
264
- luna_quantum-1.0.8rc2.dist-info/RECORD,,
267
+ luna_quantum-1.0.8rc3.dist-info/RECORD,,