From d98dee0dbdcf48169b07d6da930e5114a2c3ceaf Mon Sep 17 00:00:00 2001 From: Yusuke Kimura Date: Wed, 6 Nov 2024 15:52:16 +0100 Subject: [PATCH] Renaming (EachX/Y --> NoiseX/Y) --- src/mqt/qudits/quantum_circuit/circuit.py | 18 ++++++++++++------ .../qudits/quantum_circuit/gates/__init__.py | 8 ++++---- .../gates/{eachx.py => noise_x.py} | 4 ++-- .../gates/{eachy.py => noise_y.py} | 4 ++-- .../noise_tools/noisy_circuit_factory.py | 4 ++-- .../test_noise_tools_mathematical.py | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) rename src/mqt/qudits/quantum_circuit/gates/{eachx.py => noise_x.py} (98%) rename src/mqt/qudits/quantum_circuit/gates/{eachy.py => noise_y.py} (98%) diff --git a/src/mqt/qudits/quantum_circuit/circuit.py b/src/mqt/qudits/quantum_circuit/circuit.py index 01ab610..333b502 100644 --- a/src/mqt/qudits/quantum_circuit/circuit.py +++ b/src/mqt/qudits/quantum_circuit/circuit.py @@ -16,10 +16,10 @@ CustomMulti, CustomOne, CustomTwo, - EachX, - EachY, GellMann, H, + NoiseX, + NoiseY, Perm, R, RandU, @@ -271,12 +271,18 @@ def rz(self, qudit: int, parameters: list[int | float], controls: ControlData | return Rz(self, "Rz" + str(self.dimensions[qudit]), qudit, parameters, self.dimensions[qudit], controls) @add_gate_decorator - def eachx(self, qudit: int, parameters: list[int], controls: ControlData | None = None) -> EachX: - return EachX(self, "Xeach" + str(self.dimensions[qudit]), qudit, parameters, self.dimensions[qudit], controls) + def noisex(self, qudit: int, parameters: list[int], controls: ControlData | None = None) -> NoiseX: + return NoiseX(self, "Xeach" + str(self.dimensions[qudit]), qudit, parameters, self.dimensions[qudit], controls) @add_gate_decorator - def eachy(self, qudit: int, parameters: list[int], controls: ControlData | None = None) -> EachY: - return EachY(self, "Yeach" + str(self.dimensions[qudit]), qudit, parameters, self.dimensions[qudit], controls) + def noisey(self, qudit: int, parameters: list[int], controls: ControlData | None = None) -> NoiseY: + return NoiseY(self, "Yeach" + str(self.dimensions[qudit]), qudit, parameters, self.dimensions[qudit], controls) + + @add_gate_decorator + def noisez(self, qudit: int, level: int, controls: ControlData | None = None) -> VirtRz: + return VirtRz( + self, "VirtRz" + str(self.dimensions[qudit]), qudit, [level, np.pi], self.dimensions[qudit], controls + ) @add_gate_decorator def virtrz(self, qudit: int, parameters: list[int | float], controls: ControlData | None = None) -> VirtRz: diff --git a/src/mqt/qudits/quantum_circuit/gates/__init__.py b/src/mqt/qudits/quantum_circuit/gates/__init__.py index 5d4d0e9..6556d3c 100644 --- a/src/mqt/qudits/quantum_circuit/gates/__init__.py +++ b/src/mqt/qudits/quantum_circuit/gates/__init__.py @@ -9,12 +9,12 @@ from .custom_one import CustomOne from .custom_two import CustomTwo from .cx import CEx -from .eachx import EachX -from .eachy import EachY from .gellmann import GellMann from .h import H from .ls import LS from .ms import MS +from .noise_x import NoiseX +from .noise_y import NoiseY from .perm import Perm from .r import R from .randu import RandU @@ -34,11 +34,11 @@ "CustomMulti", "CustomOne", "CustomTwo", - "EachX", - "EachY", "GateTypes", "GellMann", "H", + "NoiseX", + "NoiseY", "Perm", "R", "RandU", diff --git a/src/mqt/qudits/quantum_circuit/gates/eachx.py b/src/mqt/qudits/quantum_circuit/gates/noise_x.py similarity index 98% rename from src/mqt/qudits/quantum_circuit/gates/eachx.py rename to src/mqt/qudits/quantum_circuit/gates/noise_x.py index 1338f9c..9cdef08 100644 --- a/src/mqt/qudits/quantum_circuit/gates/eachx.py +++ b/src/mqt/qudits/quantum_circuit/gates/noise_x.py @@ -15,7 +15,7 @@ from ..gate import Parameter -class EachX(Gate): +class NoiseX(Gate): def __init__( self, circuit: QuantumCircuit, @@ -32,7 +32,7 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, - qasm_tag="eachx", + qasm_tag="noisex", ) if self.validate_parameter(parameters): diff --git a/src/mqt/qudits/quantum_circuit/gates/eachy.py b/src/mqt/qudits/quantum_circuit/gates/noise_y.py similarity index 98% rename from src/mqt/qudits/quantum_circuit/gates/eachy.py rename to src/mqt/qudits/quantum_circuit/gates/noise_y.py index e7aa268..afb67d9 100644 --- a/src/mqt/qudits/quantum_circuit/gates/eachy.py +++ b/src/mqt/qudits/quantum_circuit/gates/noise_y.py @@ -15,7 +15,7 @@ from ..gate import Parameter -class EachY(Gate): +class NoiseY(Gate): def __init__( self, circuit: QuantumCircuit, @@ -32,7 +32,7 @@ def __init__( target_qudits=target_qudits, dimensions=dimensions, control_set=controls, - qasm_tag="eachy", + qasm_tag="noisey", ) if self.validate_parameter(parameters): diff --git a/src/mqt/qudits/simulation/noise_tools/noisy_circuit_factory.py b/src/mqt/qudits/simulation/noise_tools/noisy_circuit_factory.py index 4cd5510..12de5ee 100644 --- a/src/mqt/qudits/simulation/noise_tools/noisy_circuit_factory.py +++ b/src/mqt/qudits/simulation/noise_tools/noisy_circuit_factory.py @@ -122,11 +122,11 @@ def _apply_depolarizing_noise( accum_prob = prob_each for _lev_a, _lev_b in combinations(levels, 2): if self.rng.random() < prob_each: - noisy_circuit.eachx(dit, [_lev_a, _lev_b]) # X01, X02, X12 in qutrit + noisy_circuit.noisex(dit, [_lev_a, _lev_b]) # X01, X02, X12 in qutrit return accum_prob += prob_each if self.rng.random() < prob_each: - noisy_circuit.eachy(dit, [_lev_a, _lev_b]) # Y01, Y02, Y12 in qutrit + noisy_circuit.noisey(dit, [_lev_a, _lev_b]) # Y01, Y02, Y12 in qutrit return accum_prob += prob_each if self.rng.random() < prob_each: diff --git a/test/python/simulation/noise_tools/test_noise_tools_mathematical.py b/test/python/simulation/noise_tools/test_noise_tools_mathematical.py index dcc80d2..c2cee77 100644 --- a/test/python/simulation/noise_tools/test_noise_tools_mathematical.py +++ b/test/python/simulation/noise_tools/test_noise_tools_mathematical.py @@ -84,7 +84,7 @@ def test_generate_circuit(self): insts_new += 1 tag_counts_list2[gate.qasm_tag] += 1 - keys_to_check = ["eachx", "eachy", "virtrz"] + keys_to_check = ["noisex", "noisey", "virtrz"] valid_stochasticity = True # Iterate over all keys for key in tag_counts_list1.keys() | tag_counts_list2.keys():