Skip to content

Commit

Permalink
(resolves #83) Add qubit to src imports and run black formatter
Browse files Browse the repository at this point in the history
Problem
- Project runs black formatter
- qubit needs to be included in root import

Solution
- run `black qcpy/`
- add `from ./qubit import *`
  • Loading branch information
fabie37 committed Sep 20, 2024
1 parent fd8fa14 commit e0449de
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .quantum_gate import gates
from .visualize import *
from .tools import *
from .qubit import *
9 changes: 3 additions & 6 deletions src/quantum_circuit/quantum_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ def qft(self, qubit_one: int, qubit_two: int, qubit_three: int) -> None:
self.calculator.pass_multi_gate(qubit_one, qubit_three, paulix())
self.calculator.pass_multi_gate(qubit_three, qubit_one, paulix())
self.calculator.pass_multi_gate(qubit_one, qubit_three, paulix())
self.circuit_drawing.add_block(
"QFT", [qubit_one, qubit_two, qubit_three])
self.circuit_drawing.add_block("QFT", [qubit_one, qubit_two, qubit_three])

def rccx(self, control_one: int, control_two: int, target: int) -> None:
self.calculator.pass_single_gate(target, u(np.pi / 2, 0, np.pi))
Expand All @@ -229,8 +228,7 @@ def rccx(self, control_one: int, control_two: int, target: int) -> None:
self.calculator.pass_multi_gate(control_two, target, paulix())
self.calculator.pass_single_gate(target, u(0, 0, (-1 * np.pi) / 4))
self.calculator.pass_single_gate(target, u(np.pi / 2, 0, np.pi))
self.circuit_drawing.add_block(
"RCCX", [control_one, control_two, target])
self.circuit_drawing.add_block("RCCX", [control_one, control_two, target])

def rc3x(self, qubit_1: int, qubit_2: int, qubit_3: int, qubit_4: int) -> None:
self.calculator.pass_single_gate(qubit_4, u(np.pi / 2, 0, np.pi))
Expand All @@ -251,8 +249,7 @@ def rc3x(self, qubit_1: int, qubit_2: int, qubit_3: int, qubit_4: int) -> None:
self.calculator.pass_multi_gate(qubit_3, qubit_4, paulix())
self.calculator.pass_single_gate(qubit_4, u(0, 0, (-1 * np.pi / 4)))
self.calculator.pass_single_gate(qubit_4, u(np.pi / 2, 0, np.pi))
self.circuit_drawing.add_block(
"RC3X", [qubit_1, qubit_2, qubit_3, qubit_4])
self.circuit_drawing.add_block("RC3X", [qubit_1, qubit_2, qubit_3, qubit_4])

def swap(self, qubit_one: int, qubit_two: int) -> None:
self.calculator.pass_multi_gate(qubit_one, qubit_two, paulix())
Expand Down
1 change: 0 additions & 1 deletion src/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from .measure import measure
from .probability import probability
from .phase_angle import phase_angle as phaseangle
Expand Down
5 changes: 4 additions & 1 deletion src/tools/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@


def probability(
quantum_state: Union[ndarray, QuantumCircuit], show_percent: bool = False, show_bit: int = -1, round: int = 3
quantum_state: Union[ndarray, QuantumCircuit],
show_percent: bool = False,
show_bit: int = -1,
round: int = 3,
):

circuit_size = int(log2(quantum_state.size))
Expand Down

0 comments on commit e0449de

Please sign in to comment.