From f4369eabd59f84c47a28c8bfb93b9313c47fe13d Mon Sep 17 00:00:00 2001 From: burgholzer Date: Fri, 6 Sep 2024 16:21:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20address=20a=20couple=20more=20wa?= =?UTF-8?q?rnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mqt/qudits/compiler/dit_compiler.py | 1 - .../phy_local_adaptive_decomp.py | 60 ++++--------------- .../state_compilation/state_preparation.py | 8 +-- .../components/classic_register.py | 3 + src/mqt/qudits/quantum_circuit/gate.py | 15 +++-- src/mqt/qudits/quantum_circuit/gates/csum.py | 2 +- .../quantum_circuit/gates/custom_multi.py | 3 +- .../quantum_circuit/gates/custom_one.py | 2 +- .../quantum_circuit/gates/custom_two.py | 2 +- src/mqt/qudits/quantum_circuit/gates/cx.py | 9 ++- .../qudits/quantum_circuit/gates/gellmann.py | 12 ++-- src/mqt/qudits/quantum_circuit/gates/h.py | 2 +- src/mqt/qudits/quantum_circuit/gates/ls.py | 4 +- src/mqt/qudits/quantum_circuit/gates/ms.py | 4 +- src/mqt/qudits/quantum_circuit/gates/perm.py | 3 +- src/mqt/qudits/quantum_circuit/gates/r.py | 2 +- src/mqt/qudits/quantum_circuit/gates/randu.py | 2 +- src/mqt/qudits/quantum_circuit/gates/rh.py | 2 +- src/mqt/qudits/quantum_circuit/gates/rz.py | 2 +- src/mqt/qudits/quantum_circuit/gates/s.py | 2 +- .../qudits/quantum_circuit/gates/virt_rz.py | 2 +- src/mqt/qudits/quantum_circuit/gates/x.py | 2 +- src/mqt/qudits/quantum_circuit/gates/z.py | 2 +- .../backends/fake_backends/fake_traps2six.py | 17 ++---- .../fake_backends/fake_traps2three.py | 14 ++--- .../backends/fake_backends/fake_traps3six.py | 13 ++-- 26 files changed, 76 insertions(+), 114 deletions(-) diff --git a/src/mqt/qudits/compiler/dit_compiler.py b/src/mqt/qudits/compiler/dit_compiler.py index 50039ad..f7896ea 100644 --- a/src/mqt/qudits/compiler/dit_compiler.py +++ b/src/mqt/qudits/compiler/dit_compiler.py @@ -68,7 +68,6 @@ def compile_O0(self, backend: Backend, circuit: QuantumCircuit) -> QuantumCircui @staticmethod def compile_O1(backend: Backend, circuit: QuantumCircuit) -> QuantumCircuit: # noqa: N802 - phyloc = PhyLocAdaPass(backend) phyent = PhyEntQRCEXPass(backend) lanes = Lanes(circuit) diff --git a/src/mqt/qudits/compiler/onedit/mapping_aware_transpilation/phy_local_adaptive_decomp.py b/src/mqt/qudits/compiler/onedit/mapping_aware_transpilation/phy_local_adaptive_decomp.py index 9fc5528..265ab20 100644 --- a/src/mqt/qudits/compiler/onedit/mapping_aware_transpilation/phy_local_adaptive_decomp.py +++ b/src/mqt/qudits/compiler/onedit/mapping_aware_transpilation/phy_local_adaptive_decomp.py @@ -1,5 +1,6 @@ from __future__ import annotations +import contextlib import gc import itertools from typing import TYPE_CHECKING, cast @@ -101,23 +102,22 @@ def execute(self) -> tuple[list[Gate], tuple[float, float], LevelGraph]: self.cost_limit, [], ) - try: + + with contextlib.suppress(SequenceFoundError): self.dfs(self.TREE.root) - except SequenceFoundError: + + matrices_decomposed, best_cost, final_graph = self.TREE.retrieve_decomposition(self.TREE.root) + matrices_decomposed_m: list[Gate] = [] + if matrices_decomposed: + matrices_decomposed_m, final_graph = self.z_extraction( + matrices_decomposed, final_graph, self.phase_propagation + ) + else: pass - finally: - matrices_decomposed, best_cost, final_graph = self.TREE.retrieve_decomposition(self.TREE.root) - matrices_decomposed_m: list[Gate] = [] - if matrices_decomposed != []: - matrices_decomposed_m, final_graph = self.z_extraction( - matrices_decomposed, final_graph, self.phase_propagation - ) - else: - pass - self.TREE.print_tree(self.TREE.root, "TREE: ") + self.TREE.print_tree(self.TREE.root, "TREE: ") - return matrices_decomposed_m, best_cost, final_graph # noqa: B012 + return matrices_decomposed_m, best_cost, final_graph def z_extraction( self, decomposition: list[TreeNode], placement: LevelGraph, phase_propagation: bool @@ -209,21 +209,12 @@ def dfs(self, current_root: TreeNode, level: int = 0) -> None: raise SequenceFoundError(current_root.key) - ################################################ - ############### - ######### - - # BEGIN SEARCH - u_ = current_root.u_of_level dimension = u_.shape[0] for c, r, r2 in itertools.product(range(dimension), range(dimension), range(dimension)): if r < c or r2 <= r: continue - # for c in range(dimension): - # for r in range(c, dimension): - # for r2 in range(r + 1, dimension): if abs(u_[r2, c]) > 1.0e-8 and (abs(u_[r, c]) > 1.0e-18 or abs(u_[r, c]) == 0): theta = 2 * np.arctan2(abs(u_[r2, c]), abs(u_[r, c])) @@ -249,12 +240,8 @@ def dfs(self, current_root: TreeNode, level: int = 0) -> None: decomp_next_step_cost = cost_of_pi_pulses + gate_cost + current_root.current_decomp_cost branch_condition = current_root.max_cost[1] - decomp_next_step_cost # SECOND POSITION IS PHYSICAL COST - # branch_condition_2 = current_root.max_cost[0] - next_step_cost - # deprecated: FIRST IS ALGORITHMIC COST - if branch_condition > 0 or abs(branch_condition) < 1.0e-12: # if cost is better can be only candidate otherwise try them all - self.TREE.global_id_counter += 1 new_key = self.TREE.global_id_counter @@ -267,25 +254,9 @@ def dfs(self, current_root: TreeNode, level: int = 0) -> None: [new_placement.nodes[r]["lpmap"], new_placement.nodes[r2]["lpmap"], theta, phi], self.dimension, ) - # R(theta, phi, new_placement.nodes[r]['lpmap'], - # new_placement.nodes[r2]['lpmap'], dimension) - # physical_rotation = gate_chain_condition(pi_pulses_routing, physical_rotation) physical_rotation = graph_rule_ongate(physical_rotation, new_placement) - """"# take care of phases accumulated by not pi-pulsing back - p_backs = [] - for ppulse in pi_pulses_routing: - p_backs.append( - gates.R( - self.circuit, - "R", - self.qudit_index, - [ppulse.lev_a, ppulse.lev_b, ppulse.theta, -ppulse.phi], - self.dimension, - ) - ) - """ p_backs = [ gates.R( self.circuit, @@ -296,7 +267,6 @@ def dfs(self, current_root: TreeNode, level: int = 0) -> None: ) for ppulse in pi_pulses_routing ] - # p_backs.append(R(ppulse.theta, -ppulse.phi, ppulse.lev_a, ppulse.lev_b, dimension)) for p_back in p_backs: graph_rule_update(p_back, new_placement) @@ -312,10 +282,6 @@ def dfs(self, current_root: TreeNode, level: int = 0) -> None: pi_pulses_routing, ) - # ===============CONTINUE SEARCH ON CHILDREN======================================== if current_root.children is not None: for child in current_root.children: self.dfs(child, level + 1) - # =================================================================================== - - # END OF RECURSION# diff --git a/src/mqt/qudits/compiler/state_compilation/state_preparation.py b/src/mqt/qudits/compiler/state_compilation/state_preparation.py index d186a64..3baa55b 100644 --- a/src/mqt/qudits/compiler/state_compilation/state_preparation.py +++ b/src/mqt/qudits/compiler/state_compilation/state_preparation.py @@ -21,8 +21,6 @@ from mqt.qudits.core.micro_dd import MicroDDNode, NodeContribution from mqt.qudits.quantum_circuit import QuantumCircuit - complex_array = NDArray[np.complex128] - def find_complex_number(x: complex, c: complex) -> complex: a = x.real # Real part of x @@ -142,9 +140,9 @@ def synthesis( return if node.weight is not None: rotations = self.retrieve_local_sequence(node.weight, node.children) - - for key in sorted(rotations.keys()): - circuit_meta.append(Operation(controls, labels[depth], key, rotations[key])) # noqa: PERF401 + circuit_meta.extend([ + Operation(controls, labels[depth], key, rotations[key]) for key in sorted(rotations.keys()) + ]) if not node.reduced: for i in range(cardinalities[depth]): diff --git a/src/mqt/qudits/quantum_circuit/components/classic_register.py b/src/mqt/qudits/quantum_circuit/components/classic_register.py index b2d8465..304b559 100644 --- a/src/mqt/qudits/quantum_circuit/components/classic_register.py +++ b/src/mqt/qudits/quantum_circuit/components/classic_register.py @@ -41,3 +41,6 @@ def __getitem__(self, key: int | slice) -> int | list[int]: return [self.local_sitemap[i] for i in range(start, stop)] return self.local_sitemap[key] + + +__all__ = ["ClSitemap", "ClassicRegister"] diff --git a/src/mqt/qudits/quantum_circuit/gate.py b/src/mqt/qudits/quantum_circuit/gate.py index 82f458a..bfe3e35 100644 --- a/src/mqt/qudits/quantum_circuit/gate.py +++ b/src/mqt/qudits/quantum_circuit/gate.py @@ -40,6 +40,11 @@ def __init__( params: Parameter = None, control_set: ControlData | None = None, label: str | None = None, + lev_a: int = 0, + lev_b: int = 0, + theta: float = 0.0, + phi: float = 0.0, + qasm_tag: str = "", ) -> None: self.dagger = False self.parent_circuit = circuit @@ -55,11 +60,11 @@ def __init__( self.is_long_range = self.check_long_range() # inheritable parameters - self.lev_a: int = 0 - self.lev_b: int = 0 - self.theta: float = 0.0 - self.phi: float = 0.0 - self.qasm_tag = "" + self.lev_a: int = lev_a + self.lev_b: int = lev_b + self.theta: float = theta + self.phi: float = phi + self.qasm_tag = qasm_tag @property def reference_lines(self) -> list[int]: diff --git a/src/mqt/qudits/quantum_circuit/gates/csum.py b/src/mqt/qudits/quantum_circuit/gates/csum.py index ff31912..de3d441 100644 --- a/src/mqt/qudits/quantum_circuit/gates/csum.py +++ b/src/mqt/qudits/quantum_circuit/gates/csum.py @@ -33,8 +33,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="csum", ) - self.qasm_tag = "csum" def __array__(self) -> NDArray[np.complex128, np.complex128]: # noqa: PLW3201 qudits_targeted = cast(list[int], self.target_qudits) diff --git a/src/mqt/qudits/quantum_circuit/gates/custom_multi.py b/src/mqt/qudits/quantum_circuit/gates/custom_multi.py index 9d77418..7afc3d5 100644 --- a/src/mqt/qudits/quantum_circuit/gates/custom_multi.py +++ b/src/mqt/qudits/quantum_circuit/gates/custom_multi.py @@ -34,13 +34,12 @@ def __init__( dimensions=dimensions, control_set=controls, params=parameters, + qasm_tag="cumulti", ) self.__array_storage: NDArray = None if self.validate_parameter(parameters): self.__array_storage = parameters - self.qasm_tag = "cumulti" - def __array__(self) -> NDArray: # noqa: PLW3201 return self.__array_storage diff --git a/src/mqt/qudits/quantum_circuit/gates/custom_one.py b/src/mqt/qudits/quantum_circuit/gates/custom_one.py index b65026e..db6aff2 100644 --- a/src/mqt/qudits/quantum_circuit/gates/custom_one.py +++ b/src/mqt/qudits/quantum_circuit/gates/custom_one.py @@ -34,11 +34,11 @@ def __init__( dimensions=dimensions, control_set=controls, params=parameters, + qasm_tag="cuone", ) self.__array_storage: NDArray = None if self.validate_parameter(parameters): self.__array_storage = parameters - self.qasm_tag = "cuone" def __array__(self) -> NDArray: # noqa: PLW3201 return self.__array_storage diff --git a/src/mqt/qudits/quantum_circuit/gates/custom_two.py b/src/mqt/qudits/quantum_circuit/gates/custom_two.py index b05e9a6..d51703b 100644 --- a/src/mqt/qudits/quantum_circuit/gates/custom_two.py +++ b/src/mqt/qudits/quantum_circuit/gates/custom_two.py @@ -34,11 +34,11 @@ def __init__( dimensions=dimensions, control_set=controls, params=parameters, + qasm_tag="cutwo", ) self.__array_storage: NDArray = None if self.validate_parameter(parameters): self.__array_storage = parameters - self.qasm_tag = "cutwo" def __array__(self) -> NDArray: # noqa: PLW3201 return self.__array_storage diff --git a/src/mqt/qudits/quantum_circuit/gates/cx.py b/src/mqt/qudits/quantum_circuit/gates/cx.py index 7b3ab07..b7adc88 100644 --- a/src/mqt/qudits/quantum_circuit/gates/cx.py +++ b/src/mqt/qudits/quantum_circuit/gates/cx.py @@ -35,6 +35,9 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="cx", + lev_b=1, + params=[0, 1, 1, 0.0], ) # if customized if parameters is not None and self.validate_parameter(parameters): @@ -45,11 +48,7 @@ def __init__( # self.lev_a, self.lev_b, self.ctrl_lev, self.phi = parameters self._params: list[int | float] = parameters else: - # Default - self.lev_a, self.lev_b, self.ctrl_lev, self.phi = (0, 1, 1, 0.0) - self._params = [0, 1, 1, 0.0] - - self.qasm_tag = "cx" + self.ctrl_lev = 1 def __array__(self) -> NDArray: # noqa: PLW3201 levels_swap_low: int = cast(int, self._params[0]) diff --git a/src/mqt/qudits/quantum_circuit/gates/gellmann.py b/src/mqt/qudits/quantum_circuit/gates/gellmann.py index bd25b8e..765c669 100644 --- a/src/mqt/qudits/quantum_circuit/gates/gellmann.py +++ b/src/mqt/qudits/quantum_circuit/gates/gellmann.py @@ -27,6 +27,7 @@ def __init__( dimensions: int, controls: ControlData | None = None, ) -> None: + assert self.validate_parameter(parameters), "Invalid parameters" super().__init__( circuit=circuit, name=name, @@ -34,13 +35,12 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="gell", + lev_a=cast(int, parameters[0]), + lev_b=cast(int, parameters[1]), + params=parameters, ) - if self.validate_parameter(parameters): - self.lev_a = cast(int, parameters[0]) - self.lev_b = cast(int, parameters[1]) - self.type_m = cast(str, parameters[2]) - self._params = parameters - self.qasm_tag = "gell" + self.type_m = cast(str, parameters[2]) def __array__(self) -> NDArray: # noqa: PLW3201 d = self._dimensions diff --git a/src/mqt/qudits/quantum_circuit/gates/h.py b/src/mqt/qudits/quantum_circuit/gates/h.py index 8ec7745..cdf5787 100644 --- a/src/mqt/qudits/quantum_circuit/gates/h.py +++ b/src/mqt/qudits/quantum_circuit/gates/h.py @@ -31,8 +31,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="h", ) - self.qasm_tag = "h" def __array__(self) -> NDArray: # noqa: PLW3201 matrix = np.zeros((self.dimensions, self.dimensions), dtype="complex") diff --git a/src/mqt/qudits/quantum_circuit/gates/ls.py b/src/mqt/qudits/quantum_circuit/gates/ls.py index fbdefaa..79b720e 100644 --- a/src/mqt/qudits/quantum_circuit/gates/ls.py +++ b/src/mqt/qudits/quantum_circuit/gates/ls.py @@ -36,11 +36,13 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="ls", + params=parameters, + theta=parameters[0], ) if self.validate_parameter(parameters): self.theta = parameters[0] self._params = parameters - self.qasm_tag = "ls" def __array__(self) -> NDArray: # noqa: PLW3201 dimension_0 = self.dimensions[0] diff --git a/src/mqt/qudits/quantum_circuit/gates/ms.py b/src/mqt/qudits/quantum_circuit/gates/ms.py index a770b95..6a9924e 100644 --- a/src/mqt/qudits/quantum_circuit/gates/ms.py +++ b/src/mqt/qudits/quantum_circuit/gates/ms.py @@ -34,11 +34,13 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="ms", + params=parameters, + theta=parameters[0], ) if self.validate_parameter(parameters): self.theta = parameters[0] self._params = parameters - self.qasm_tag = "ms" def __array__(self) -> NDArray: # noqa: PLW3201 theta = self.theta diff --git a/src/mqt/qudits/quantum_circuit/gates/perm.py b/src/mqt/qudits/quantum_circuit/gates/perm.py index 4cdf762..08fc849 100644 --- a/src/mqt/qudits/quantum_circuit/gates/perm.py +++ b/src/mqt/qudits/quantum_circuit/gates/perm.py @@ -32,11 +32,12 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + params=parameters, + qasm_tag="pm", ) if self.validate_parameter(parameters): self.perm_data = parameters self._params = parameters - self.qasm_tag = "pm" def __array__(self) -> NDArray: # noqa: PLW3201 return np.eye(self.dimensions)[:, self.perm_data] diff --git a/src/mqt/qudits/quantum_circuit/gates/r.py b/src/mqt/qudits/quantum_circuit/gates/r.py index a20927a..7c98cc8 100644 --- a/src/mqt/qudits/quantum_circuit/gates/r.py +++ b/src/mqt/qudits/quantum_circuit/gates/r.py @@ -34,6 +34,7 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="rxy", ) if self.validate_parameter(parameters): @@ -44,7 +45,6 @@ def __init__( self.lev_a, self.lev_b = self.levels_setter(self.original_lev_a, self.original_lev_b) self.theta = regulate_theta(self.theta) self._params = parameters - self.qasm_tag = "rxy" def __array__(self) -> NDArray: # noqa: PLW3201 dimension = self.dimensions diff --git a/src/mqt/qudits/quantum_circuit/gates/randu.py b/src/mqt/qudits/quantum_circuit/gates/randu.py index 2d42d0c..bf2aabc 100644 --- a/src/mqt/qudits/quantum_circuit/gates/randu.py +++ b/src/mqt/qudits/quantum_circuit/gates/randu.py @@ -34,8 +34,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="rdu", ) - self.qasm_tag = "rdu" def __array__(self) -> NDArray[np.complex128, np.complex128]: # noqa: PLW3201 dim = reduce(operator.mul, self.dimensions) diff --git a/src/mqt/qudits/quantum_circuit/gates/rh.py b/src/mqt/qudits/quantum_circuit/gates/rh.py index d3bc775..7fa06f8 100644 --- a/src/mqt/qudits/quantum_circuit/gates/rh.py +++ b/src/mqt/qudits/quantum_circuit/gates/rh.py @@ -35,13 +35,13 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="rh", ) if self.validate_parameter(parameters): self.original_lev_a = parameters[0] self.original_lev_b = parameters[1] self.lev_a, self.lev_b = self.levels_setter(self.original_lev_a, self.original_lev_b) self._params = parameters - self.qasm_tag = "rh" def __array__(self) -> NDArray: # noqa: PLW3201 # (R(-np.pi, 0, l1, l2, dim) * R(np.pi / 2, np.pi / 2, l1, l2, dim)) diff --git a/src/mqt/qudits/quantum_circuit/gates/rz.py b/src/mqt/qudits/quantum_circuit/gates/rz.py index 233a204..03cbd4c 100644 --- a/src/mqt/qudits/quantum_circuit/gates/rz.py +++ b/src/mqt/qudits/quantum_circuit/gates/rz.py @@ -34,6 +34,7 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="rz", ) if self.validate_parameter(parameters): self.original_lev_a: int = cast(int, parameters[0]) @@ -42,7 +43,6 @@ def __init__( self.phi = regulate_theta(self.phi) self.lev_a, self.lev_b = self.levels_setter(self.original_lev_a, self.original_lev_b) self._params = parameters - self.qasm_tag = "rz" def __array__(self) -> NDArray[np.complex128, np.complex128]: # noqa: PLW3201 dimension = self.dimensions diff --git a/src/mqt/qudits/quantum_circuit/gates/s.py b/src/mqt/qudits/quantum_circuit/gates/s.py index 0346b32..44ae0ac 100644 --- a/src/mqt/qudits/quantum_circuit/gates/s.py +++ b/src/mqt/qudits/quantum_circuit/gates/s.py @@ -32,8 +32,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="s", ) - self.qasm_tag = "s" else: msg = "S can be applied to prime dimensional qudits" raise InvalidQuditDimensionError(msg) diff --git a/src/mqt/qudits/quantum_circuit/gates/virt_rz.py b/src/mqt/qudits/quantum_circuit/gates/virt_rz.py index 288f106..b5be526 100644 --- a/src/mqt/qudits/quantum_circuit/gates/virt_rz.py +++ b/src/mqt/qudits/quantum_circuit/gates/virt_rz.py @@ -33,13 +33,13 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="virtrz", ) if self.validate_parameter(parameters): self.lev_a: int = cast(int, parameters[0]) self.phi: float = cast(float, parameters[1]) self.phi = regulate_theta(self.phi) self._params = parameters - self.qasm_tag = "virtrz" def __array__(self) -> NDArray: # noqa: PLW3201 dimension = self.dimensions diff --git a/src/mqt/qudits/quantum_circuit/gates/x.py b/src/mqt/qudits/quantum_circuit/gates/x.py index 19bc4a2..1ee4b9d 100644 --- a/src/mqt/qudits/quantum_circuit/gates/x.py +++ b/src/mqt/qudits/quantum_circuit/gates/x.py @@ -30,8 +30,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="x", ) - self.qasm_tag = "x" def __array__(self) -> NDArray: # noqa: PLW3201 matrix = np.zeros((self.dimensions, self.dimensions), dtype="complex") diff --git a/src/mqt/qudits/quantum_circuit/gates/z.py b/src/mqt/qudits/quantum_circuit/gates/z.py index 6d313b1..f8c1b3e 100644 --- a/src/mqt/qudits/quantum_circuit/gates/z.py +++ b/src/mqt/qudits/quantum_circuit/gates/z.py @@ -30,8 +30,8 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, + qasm_tag="z", ) - self.qasm_tag = "z" def __array__(self) -> NDArray: # noqa: PLW3201 matrix = np.zeros((self.dimensions, self.dimensions), dtype="complex") diff --git a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2six.py b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2six.py index b4b124a..23647d6 100644 --- a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2six.py +++ b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2six.py @@ -15,22 +15,13 @@ class FakeIonTraps2Six(TNSim): def version(self) -> int: return 0 - def __init__( - self, - provider: MQTQuditProvider, - **fields: dict[str, int | bool | NoiseModel | None], - ) -> None: - self._options = self._default_options() - self._provider = provider - - self.name = "FakeTrap2Six" - self.description = "A Fake backend of an ion trap qudit machine" + def __init__(self, provider: MQTQuditProvider, **fields: dict[str, int | bool | NoiseModel | None]) -> None: + super().__init__( + provider=provider, name="FakeTrap2Six", description="A Fake backend of an ion trap qudit machine", **fields + ) self.author = "" self._energy_level_graphs: list[LevelGraph] = [] - if fields: - self._options.update(fields) # type: ignore[arg-type] - @property def energy_level_graphs(self) -> list[LevelGraph]: if len(self._energy_level_graphs) == 0: diff --git a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2three.py b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2three.py index 4e33a97..9bf6266 100644 --- a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2three.py +++ b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps2three.py @@ -20,17 +20,15 @@ def __init__( provider: MQTQuditProvider, **fields: dict[str, Any], ) -> None: - self._options = self._default_options() - self._provider = provider - - self.name = "FakeTrap2" - self.description = "A Fake backend of an ion trap qudit machine" + super().__init__( + provider=provider, + name="FakeTrap2", + description="A Fake backend of an ion trap qudit machine", + **fields, + ) self.author = "" self._energy_level_graphs: list[LevelGraph] = [] - if fields: - self._options.update(fields) # type: ignore[arg-type] - @property def energy_level_graphs(self) -> list[LevelGraph]: if len(self._energy_level_graphs) == 0: diff --git a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps3six.py b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps3six.py index 49ed728..170343f 100644 --- a/src/mqt/qudits/simulation/backends/fake_backends/fake_traps3six.py +++ b/src/mqt/qudits/simulation/backends/fake_backends/fake_traps3six.py @@ -20,16 +20,15 @@ def __init__( provider: MQTQuditProvider, **fields: dict[str, Any], ) -> None: - self._options = self._default_options() - self._provider = provider - self.name = "FakeTrap3Six" - self.description = "A Fake backend of an ion trap qudit machine" + super().__init__( + provider=provider, + name="FakeTrap3Six", + description="A Fake backend of an ion trap qudit machine", + **fields, + ) self.author = "" self._energy_level_graphs: list[LevelGraph] = [] - if fields: - self._options.update(fields) # type: ignore[arg-type] - @property def energy_level_graphs(self) -> list[LevelGraph]: if len(self._energy_level_graphs) == 0: