Skip to content

Commit

Permalink
Renaming (EachX/Y --> NoiseX/Y)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkyusuke committed Nov 6, 2024
1 parent db417de commit d98dee0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
18 changes: 12 additions & 6 deletions src/mqt/qudits/quantum_circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
CustomMulti,
CustomOne,
CustomTwo,
EachX,
EachY,
GellMann,
H,
NoiseX,
NoiseY,
Perm,
R,
RandU,
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/mqt/qudits/quantum_circuit/gates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,11 +34,11 @@
"CustomMulti",
"CustomOne",
"CustomTwo",
"EachX",
"EachY",
"GateTypes",
"GellMann",
"H",
"NoiseX",
"NoiseY",
"Perm",
"R",
"RandU",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..gate import Parameter


class EachX(Gate):
class NoiseX(Gate):
def __init__(
self,
circuit: QuantumCircuit,
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..gate import Parameter


class EachY(Gate):
class NoiseY(Gate):
def __init__(
self,
circuit: QuantumCircuit,
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d98dee0

Please sign in to comment.