Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Jul 16, 2021
1 parent 6484be2 commit d23d079
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 391 deletions.
1 change: 0 additions & 1 deletion src/qutip_qip/_decomposition_functions/__init__.py

This file was deleted.

198 changes: 0 additions & 198 deletions src/qutip_qip/_decomposition_functions/_single_qubit_gate.py

This file was deleted.

37 changes: 20 additions & 17 deletions src/qutip_qip/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,29 +2131,32 @@ def _apply_measurement(self, operation):
raise NotImplementedError(
"mode {} is not available.".format(self.mode))


# For Decomposition functions
def decomposed_gates_to_circuit(decomposed_gate,num_qubits):
def decomposed_gates_to_circuit(decomposed_gate, num_qubits):
"""This function takes the input from a decomposition function and returns
a quantum circuit.
Parameters
----------
decomposed_gate : tuple
The output from some decomposition function in a tuple form.
"""
# as decomposed_gate contains information about targets/control, there's no
# additional input of target here.
# In addition, there's no check if the gates are valid for number of qubits
# because this is done in a decomposition function before output.
if isinstance(decomposed_gate,tuple) == True:
q_circuit = QubitCircuit(num_qubits, reverse_states=False)
for i in decomposed_gate:
q_circuit.add_gate(i)
return(q_circuit)
else:
# there's no check if the gates are valid for number of qubits
# because this is done in a decomposition function before output
if not isinstance(decomposed_gate, tuple):
raise TypeError("Input is not a tuple of gates.")
q_circuit = QubitCircuit(num_qubits, reverse_states=False)
for i in decomposed_gate:
q_circuit.add_gate(i)
return(q_circuit)


def compute_unitary(quantum_circuit):
"""Evaluates all the gates in the quantum circuit.
"""Evaluates all the gates in the quantum circuit of decomposed gates.
"""
if isinstance(quantum_circuit, QubitCircuit) == True:
gate_list = quantum_circuit.propagators()
matrix_of_all_gates = gate_sequence_product(gate_list)
return(matrix_of_all_gates)
else:
if not isinstance(quantum_circuit, QubitCircuit):
raise TypeError("Input is not of type QubitCircuit.")
gate_list = quantum_circuit.propagators()
matrix_of_all_gates = gate_sequence_product(gate_list)
return(matrix_of_all_gates)
115 changes: 0 additions & 115 deletions src/qutip_qip/decompose.py

This file was deleted.

1 change: 1 addition & 0 deletions src/qutip_qip/decompose/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .decompose_single_qubit_gate import *
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import numpy as np
import cmath

from qutip import Qobj


Expand All @@ -10,14 +7,6 @@ class MethodError(Exception):
pass


class GateError(Exception):
"""When chosen method cannot be applied to the input gate, this error
is raised.
"""

pass


def check_gate(gate, num_qubits):
"""Verifies input is a valid quantum gate.
Expand All @@ -26,7 +15,7 @@ def check_gate(gate, num_qubits):
gate : :class:`qutip.Qobj`
The matrix that's supposed to be decomposed should be a Qobj.
num_qubits:
Number of qubits in the circuit.
Total number of qubits in the circuit.
Raises
------
TypeError
Expand Down
Loading

0 comments on commit d23d079

Please sign in to comment.