qctrl-commons 25.1.3__tar.gz → 25.2.0__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 (22) hide show
  1. qctrl_commons-25.2.0/LICENSE +10 -0
  2. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/PKG-INFO +6 -9
  3. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/pyproject.toml +9 -7
  4. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/__init__.py +2 -2
  5. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/constants.py +1 -1
  6. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/core_exceptions.py +1 -1
  7. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/data_types.py +22 -4
  8. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/exceptions.py +1 -1
  9. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/graph.py +1 -1
  10. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/node/__init__.py +1 -1
  11. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/node/base.py +1 -1
  12. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/node/wrapper.py +2 -2
  13. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/pauli_operations.py +4 -4
  14. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/preconditions.py +1 -1
  15. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/pytest_plugin.py +1 -1
  16. qctrl_commons-25.2.0/qctrlcommons/run_options.py +61 -0
  17. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/serializers.py +5 -1
  18. qctrl_commons-25.2.0/qctrlcommons/simulation_types.py +188 -0
  19. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/qctrlcommons/utils.py +2 -2
  20. qctrl_commons-25.1.3/LICENSE +0 -805
  21. qctrl_commons-25.1.3/qctrlcommons/run_options.py +0 -41
  22. {qctrl_commons-25.1.3 → qctrl_commons-25.2.0}/README.md +0 -0
@@ -0,0 +1,10 @@
1
+ Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized copying
2
+ or use of this software, via any medium, is strictly prohibited. Proprietary and
3
+ confidential. You may not use this software except in compliance with the
4
+ License. You may obtain a copy of the License at
5
+
6
+ https://q-ctrl.com/terms
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed
9
+ under the License is distributed on an "AS IS" BASIS. See the License for the
10
+ specific language.
@@ -1,23 +1,21 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: qctrl-commons
3
- Version: 25.1.3
3
+ Version: 25.2.0
4
4
  Summary: Q-CTRL Commons
5
- License: https://q-ctrl.com/terms
5
+ License-File: LICENSE
6
6
  Keywords: black opal,boulder opal,fire opal,nisq,open controls,q control,q ctrl,q-control,q-ctrl,qcontrol,qctrl,quantum,quantum algorithms,quantum circuits,quantum coding,quantum coding software,quantum computing,quantum control,quantum control software,quantum control theory,quantum engineering,quantum error correction,quantum firmware,quantum fundamentals,quantum sensing,qubit,qudit
7
7
  Author: Q-CTRL
8
8
  Author-email: support@q-ctrl.com
9
9
  Maintainer: Q-CTRL
10
10
  Maintainer-email: support@q-ctrl.com
11
- Requires-Python: >=3.10,<3.14
11
+ Requires-Python: >=3.10, <3.14
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Environment :: Console
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: Intended Audience :: Education
16
16
  Classifier: Intended Audience :: Science/Research
17
- Classifier: License :: Other/Proprietary License
18
17
  Classifier: Natural Language :: English
19
18
  Classifier: Operating System :: OS Independent
20
- Classifier: Programming Language :: Python :: 3
21
19
  Classifier: Programming Language :: Python :: 3.10
22
20
  Classifier: Programming Language :: Python :: 3.11
23
21
  Classifier: Programming Language :: Python :: 3.12
@@ -30,13 +28,12 @@ Classifier: Topic :: System :: Distributed Computing
30
28
  Requires-Dist: graphql-core (>=3.2.1,<3.3.0)
31
29
  Requires-Dist: networkx (>=3.0.0,<4.0.0)
32
30
  Requires-Dist: numpy (>=2.0.2,<3.0.0) ; python_version >= "3.10" and python_version < "3.13"
33
- Requires-Dist: numpy (>=2.1.0,<3.0.0) ; python_version >= "3.13" and python_version < "3.14"
34
- Requires-Dist: scipy (>=1.14.1,<2.0.0) ; python_version >= "3.13" and python_version < "3.14"
31
+ Requires-Dist: numpy (>=2.1.0,<3.0.0) ; python_version == "3.13"
32
+ Requires-Dist: scipy (>=1.14.1,<2.0.0) ; python_version == "3.13"
35
33
  Requires-Dist: scipy (>=1.9.3) ; python_version >= "3.10" and python_version < "3.13"
36
34
  Requires-Dist: sympy (>=1.11.1,<2.0.0)
37
35
  Project-URL: Facebook, https://www.facebook.com/qctrl
38
36
  Project-URL: GitHub, https://github.com/qctrl
39
- Project-URL: Homepage, https://q-ctrl.com
40
37
  Project-URL: LinkedIn, https://www.linkedin.com/company/q-ctrl/
41
38
  Project-URL: X, https://x.com/qctrlHQ
42
39
  Project-URL: YouTube, https://www.youtube.com/c/qctrl
@@ -1,10 +1,11 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "qctrl-commons"
3
- version = "25.1.3"
3
+ version = "25.2.0"
4
4
  description = "Q-CTRL Commons"
5
- license = "https://q-ctrl.com/terms"
6
- authors = ["Q-CTRL <support@q-ctrl.com>"]
7
- maintainers = ["Q-CTRL <support@q-ctrl.com>"]
5
+ license-files = ["LICENSE"]
6
+ requires-python = ">=3.10, <3.14"
7
+ authors = [{name = "Q-CTRL", email = "support@q-ctrl.com"}]
8
+ maintainers = [{name = "Q-CTRL", email = "support@q-ctrl.com"}]
8
9
  readme = "README.md"
9
10
  homepage = "https://q-ctrl.com"
10
11
  keywords = [
@@ -54,12 +55,13 @@ classifiers = [
54
55
  "Topic :: Software Development :: Embedded Systems",
55
56
  "Topic :: System :: Distributed Computing"
56
57
  ]
58
+
59
+ [tool.poetry]
57
60
  packages = [
58
61
  { include = "qctrlcommons" },
59
62
  ]
60
63
 
61
64
  [tool.poetry.dependencies]
62
- python = ">=3.10 <3.14"
63
65
  networkx = ">=3.0.0,<4.0.0"
64
66
  numpy = [
65
67
  { version = "^2.0.2", python = ">=3.10,<3.13" },
@@ -122,5 +124,5 @@ ignore = [
122
124
  convention = "numpy" # https://numpydoc.readthedocs.io/en/latest/format.html#sections
123
125
 
124
126
  [build-system]
125
- requires = ["poetry-core"]
127
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
126
128
  build-backend = "poetry.core.masonry.api"
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -13,5 +13,5 @@
13
13
 
14
14
  """qctrlcommons - a collection of common libraries for the Python language"""
15
15
 
16
- __version__ = "25.1.3"
16
+ __version__ = "25.2.0"
17
17
  __author__ = "Q-CTRL <support@q-ctrl.com>"
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -44,6 +44,10 @@ from qctrlcommons.run_options import (
44
44
  IbmRunOptions,
45
45
  RunOptions,
46
46
  )
47
+ from qctrlcommons.simulation_types import (
48
+ ModelType,
49
+ SimulationType,
50
+ )
47
51
 
48
52
 
49
53
  def handle_built_in_iterator(obj):
@@ -55,7 +59,7 @@ def handle_built_in_iterator(obj):
55
59
  """
56
60
  if isinstance(obj, dok_matrix):
57
61
  return SparseMatrix().encode(obj)
58
- if isinstance(obj, (list, tuple)):
62
+ if isinstance(obj, list | tuple):
59
63
  return [handle_built_in_iterator(e) for e in obj]
60
64
  if isinstance(obj, dict):
61
65
  return {handle_built_in_iterator(k): handle_built_in_iterator(v) for k, v in obj.items()}
@@ -421,7 +425,7 @@ class OperationDataType(DataType):
421
425
  if isinstance(value, Node):
422
426
  return {"_kwarg_type": "node", "value": value.node_id}
423
427
 
424
- if isinstance(value, (list, tuple)):
428
+ if isinstance(value, list | tuple):
425
429
  return [self._set_kwargs_reference(input_) for input_ in value]
426
430
 
427
431
  if isinstance(value, dict) and not isinstance(value, dok_matrix):
@@ -456,7 +460,7 @@ class OperationDataType(DataType):
456
460
  return node
457
461
 
458
462
  def can_encode(self, obj: Any) -> bool:
459
- return isinstance(obj, (Operation, NodeData, Node))
463
+ return isinstance(obj, Operation | NodeData | Node)
460
464
 
461
465
 
462
466
  class FloatConstant(DataType):
@@ -621,3 +625,17 @@ class PauliOperatorDataType(DataclassType):
621
625
 
622
626
  _type = PauliOperator
623
627
  object_key = "fire_opal_pauli_operator"
628
+
629
+
630
+ class ModelTypeDataType(DataclassType):
631
+ """Handle ModelType serialization."""
632
+
633
+ _type = ModelType
634
+ object_key = "fire_opal_model_type"
635
+
636
+
637
+ class SimulationTypeDataType(DataclassType):
638
+ """Handle SimulationType serialization."""
639
+
640
+ _type = SimulationType
641
+ object_key = "fire_opal_simulation_type"
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -92,7 +92,7 @@ class Operation:
92
92
  In case any of the arguments of the current operations
93
93
  belongs to a different instance `Graph`
94
94
  """
95
- if isinstance(value, (list, tuple)):
95
+ if isinstance(value, list | tuple):
96
96
  for val in value:
97
97
  self._iter_validate_op_graph(val)
98
98
  elif isinstance(value, dict):
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -80,7 +80,7 @@ class PauliOperator:
80
80
  dict[str, complex]
81
81
  Dictionary representation of the Pauli operator.
82
82
  """
83
- return dict(zip(self.paulis, self.coefficients))
83
+ return dict(zip(self.paulis, self.coefficients, strict=False))
84
84
 
85
85
  @staticmethod
86
86
  def from_dict(pauli_dict: dict, dtype: type = complex) -> "PauliOperator":
@@ -110,7 +110,7 @@ class PauliOperator:
110
110
  list[tuple[str, complex]]
111
111
  List of tuples containing the Pauli strings and coefficients.
112
112
  """
113
- return list(zip(self.paulis, self.coefficients))
113
+ return list(zip(self.paulis, self.coefficients, strict=False))
114
114
 
115
115
  @staticmethod
116
116
  def from_list(
@@ -235,7 +235,7 @@ class PauliOperator:
235
235
  )
236
236
  # construct the full label based off the non-trivial Paulis and indices
237
237
  label = ["I"] * qubit_count
238
- for pauli, index in zip(paulis, indices):
238
+ for pauli, index in zip(paulis, indices, strict=False):
239
239
  if index >= qubit_count:
240
240
  raise QctrlArgumentsValueError(
241
241
  f"The number of qubits is smaller than a required index {index}.",
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -0,0 +1,61 @@
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
+ #
3
+ # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
+ # copying or use of this file, via any medium, is strictly prohibited.
5
+ # Proprietary and confidential. You may not use this file except in compliance
6
+ # with the License. You may obtain a copy of the License at
7
+ #
8
+ # https://q-ctrl.com/terms
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS. See the
12
+ # License for the specific language.
13
+ """Dataclasses defining options for Fire Opal circuit execution."""
14
+
15
+ from dataclasses import dataclass
16
+
17
+
18
+ @dataclass
19
+ class RunOptions:
20
+ """
21
+ Provider-agnostic options for Fire Opal circuit execution.
22
+ """
23
+
24
+
25
+ @dataclass
26
+ class IbmRunOptions(RunOptions):
27
+ """
28
+ Options for configuring circuit execution on IBM Quantum devices through Fire Opal.
29
+
30
+ Use this dataclass to specify IBM-specific execution options when submitting
31
+ quantum circuits via Fire Opal.
32
+
33
+ Parameters
34
+ ----------
35
+ session_id : str or None, optional
36
+ The ID of an existing IBM Runtime session to use for circuit execution.
37
+ When provided, the submitted jobs will run within the specified session,
38
+ enabling grouped execution and resource sharing across multiple calls.
39
+ Defaults to None, in which case Fire Opal will create a new session
40
+ for iterative workloads, such as :func:`~fireopal.solve_qaoa` or :func:`~fireopal.iterate`.
41
+ job_tags : list of str or None, optional
42
+ A list of tags to append to the jobs submitted to IBM Quantum. Tags are
43
+ useful for filtering and identifying jobs in the IBM Quantum dashboard.
44
+ Defaults to None, meaning no additional tags are applied.
45
+
46
+ Examples
47
+ --------
48
+ Execute circuits within an existing IBM Runtime session with custom tags:
49
+
50
+ >>> options = IbmRunOptions(
51
+ ... session_id="<your_session_id>",
52
+ ... job_tags=["experiment-1", "calibration"],
53
+ ... )
54
+
55
+ Use default options (no session, no tags):
56
+
57
+ >>> options = IbmRunOptions()
58
+ """
59
+
60
+ session_id: str | None = None
61
+ job_tags: list[str] | None = None
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -29,6 +29,7 @@ from .data_types import (
29
29
  FloatConstant,
30
30
  GraphDataType,
31
31
  IbmRunOptionsDataType,
32
+ ModelTypeDataType,
32
33
  NumpyArray,
33
34
  NumpyComplexNumber,
34
35
  NumpyScalar,
@@ -37,6 +38,7 @@ from .data_types import (
37
38
  PauliOperatorDataType,
38
39
  QuantumObject,
39
40
  RunOptionsDataType,
41
+ SimulationTypeDataType,
40
42
  SliceDataType,
41
43
  SparseMatrix,
42
44
  SympyExprDataType,
@@ -67,6 +69,8 @@ class DataTypeMixin:
67
69
  IbmRunOptionsDataType(),
68
70
  RunOptionsDataType(),
69
71
  PauliOperatorDataType(),
72
+ ModelTypeDataType(),
73
+ SimulationTypeDataType(),
70
74
  ]
71
75
 
72
76
 
@@ -0,0 +1,188 @@
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
+ #
3
+ # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
+ # copying or use of this file, via any medium, is strictly prohibited.
5
+ # Proprietary and confidential. You may not use this file except in compliance
6
+ # with the License. You may obtain a copy of the License at
7
+ #
8
+ # https://q-ctrl.com/terms
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS. See the
12
+ # License for the specific language.
13
+ """
14
+ Dataclasses defining models and time-evolution schemes for Fire Opal dynamics simulation.
15
+ """
16
+
17
+ from dataclasses import (
18
+ asdict,
19
+ dataclass,
20
+ )
21
+ from typing import Any, Literal
22
+
23
+ from qctrlcommons.exceptions import QctrlArgumentsValueError
24
+
25
+
26
+ @dataclass(frozen=True)
27
+ class ModelType:
28
+ """
29
+ Definition of the model to simulate.
30
+
31
+ Parameters
32
+ ----------
33
+ hopping_amplitude : list[float]
34
+ Hopping amplitude between sites.
35
+ on_site_interaction : list[float]
36
+ On-site interaction strength.
37
+ chemical_potential : list[float]
38
+ Chemical potential at each site.
39
+ name : str, optional
40
+ Name of the model (for example, `"Fermi-Hubbard"`). Defaults to "Fermi-Hubbard".
41
+ lattice_type : str, optional
42
+ Type of the lattice. Currently only `1D` is supported. Defaults to "1D".
43
+
44
+ Raises
45
+ ------
46
+ QctrlArgumentsValueError
47
+ If any field has an invalid type or value.
48
+ """
49
+
50
+ hopping_amplitude: list[float]
51
+ on_site_interaction: list[float]
52
+ chemical_potential: list[float]
53
+ name: Literal["Fermi-Hubbard"] = "Fermi-Hubbard"
54
+ lattice_type: Literal["1D"] = "1D"
55
+
56
+ def __post_init__(self):
57
+ if not isinstance(self.name, str):
58
+ raise QctrlArgumentsValueError(
59
+ "The model name must be a string.",
60
+ {"name": self.name},
61
+ )
62
+ if not isinstance(self.lattice_type, str):
63
+ raise QctrlArgumentsValueError(
64
+ "The model lattice_type must be a string.",
65
+ {"lattice_type": self.lattice_type},
66
+ )
67
+ if self.lattice_type != "1D":
68
+ raise QctrlArgumentsValueError(
69
+ "Unsupported lattice type. Only '1D' is currently supported.",
70
+ {"lattice_type": self.lattice_type},
71
+ )
72
+ for term_name, term_value in (
73
+ ("hopping_amplitude", self.hopping_amplitude),
74
+ ("on_site_interaction", self.on_site_interaction),
75
+ ("chemical_potential", self.chemical_potential),
76
+ ):
77
+ if not (
78
+ isinstance(term_value, list)
79
+ and all(isinstance(item, int | float) for item in term_value)
80
+ ):
81
+ raise QctrlArgumentsValueError(
82
+ f"The model {term_name} must be a list of real numbers.",
83
+ {term_name: term_value},
84
+ )
85
+
86
+ def to_dict(self) -> dict[str, Any]:
87
+ """
88
+ Serialize the model to a dictionary.
89
+
90
+ Returns
91
+ -------
92
+ dict
93
+ Dictionary representation of the model.
94
+ """
95
+ return asdict(self)
96
+
97
+ @classmethod
98
+ def from_dict(cls, data: dict) -> "ModelType":
99
+ """
100
+ Deserialize the model from a dictionary.
101
+
102
+ Parameters
103
+ ----------
104
+ data : dict
105
+ Dictionary representation of the model.
106
+
107
+ Returns
108
+ -------
109
+ ModelType
110
+ The reconstructed model definition.
111
+ """
112
+ return cls(**data)
113
+
114
+
115
+ @dataclass(frozen=True)
116
+ class SimulationType:
117
+ """
118
+ Definition of the time-evolution scheme used to simulate a model.
119
+
120
+ Parameters
121
+ ----------
122
+ time_step : float
123
+ Duration of a single time step `dt`.
124
+ step_count : int
125
+ Number of time steps to take.
126
+ method : str, optional
127
+ Time-evolution method (for example, `"trotter"`). Currently only "trotter" is
128
+ supported. Defaults to "trotter".
129
+
130
+ Raises
131
+ ------
132
+ QctrlArgumentsValueError
133
+ If any field has an invalid type or value.
134
+ """
135
+
136
+ time_step: float
137
+ step_count: int
138
+ method: Literal["trotter"] = "trotter"
139
+
140
+ def __post_init__(self):
141
+ if not isinstance(self.method, str):
142
+ raise QctrlArgumentsValueError(
143
+ "The simulation method must be a string.",
144
+ {"method": self.method},
145
+ )
146
+ if self.method != "trotter":
147
+ raise QctrlArgumentsValueError(
148
+ "Unsupported simulation method. Only 'trotter' is currently supported.",
149
+ {"method": self.method},
150
+ )
151
+ if not isinstance(self.step_count, int):
152
+ raise QctrlArgumentsValueError(
153
+ "The simulation step_count must be an integer.",
154
+ {"step_count": self.step_count},
155
+ )
156
+ if not isinstance(self.time_step, int | float):
157
+ raise QctrlArgumentsValueError(
158
+ "The simulation time_step must be a real number.",
159
+ {"time_step": self.time_step},
160
+ )
161
+
162
+ def to_dict(self) -> dict[str, Any]:
163
+ """
164
+ Serialize the simulation to a dictionary.
165
+
166
+ Returns
167
+ -------
168
+ dict
169
+ Dictionary representation of the simulation.
170
+ """
171
+ return asdict(self)
172
+
173
+ @classmethod
174
+ def from_dict(cls, data: dict) -> "SimulationType":
175
+ """
176
+ Deserialize the simulation from a dictionary.
177
+
178
+ Parameters
179
+ ----------
180
+ data : dict
181
+ Dictionary representation of the simulation.
182
+
183
+ Returns
184
+ -------
185
+ SimulationType
186
+ The reconstructed simulation definition.
187
+ """
188
+ return cls(**data)
@@ -1,4 +1,4 @@
1
- # Copyright 2025 Q-CTRL. All rights reserved.
1
+ # Copyright 2026 Q-CTRL. All rights reserved.
2
2
  #
3
3
  # Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
4
4
  # copying or use of this file, via any medium, is strictly prohibited.
@@ -112,7 +112,7 @@ def generate_user_agent(lib_name: str, version: str) -> str:
112
112
  f"Python/{platform.python_version()} "
113
113
  f"({platform.python_implementation()}) "
114
114
  f"Q-CTRL Client UUID/{generate_hashed_uuid()} "
115
- )
115
+ ).strip()
116
116
 
117
117
 
118
118
  def generate_hashed_uuid() -> str: