From 6064bd6437dfe8eebe536aa388a1c7bcaeebae1c Mon Sep 17 00:00:00 2001 From: Virginia Date: Tue, 29 Jan 2019 19:06:05 +1100 Subject: [PATCH 1/2] add todos --- README.md | 56 ++++++++++++++++++- tests/test_circuits.py | 1 + tests/test_gates.py | 1 + tests/test_qubit_register.py | 1 + two_qubit_simulator/__init__.py | 2 + two_qubit_simulator/circuits.py | 4 ++ two_qubit_simulator/quantum_gates/__init__.py | 1 + two_qubit_simulator/quantum_gates/cnot.py | 1 + .../quantum_gates/depolarising.py | 1 + two_qubit_simulator/quantum_gates/hadamard.py | 1 + .../quantum_gates/phase_gate.py | 1 + .../quantum_gates/quantum_gate.py | 1 + two_qubit_simulator/qubit_register.py | 3 + 13 files changed, 72 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c671296..b26c023 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,55 @@ -# `__equs.Python__` workshop 2019 - Coding project +# `__equs.Python__` workshop 2019 - Code project -Details to follow ... \ No newline at end of file + +**Note: to participate in this project you will need a GitHub account.** + +Now that we have covered how to build Python packagaes and how to work on Python projects on GitHub, let's all collaborate together and build a Python package that can simulate one and two qubit quantum circuits. + +We build a skeleton for this package and your task is to write the content and tests for it. + +The package is structured as followed: + +```shell +two_qubit_simulator/ + - __init__.py + - qubit_register.py + - quantum_circuit.py + - quantum_gates/ + - __init__.py + - quantum_gate.py + - hadamard.py + - cnot.py + - ... +tests/ + - test_qubit_register.py + - test_quantum_circuit.py + - test_quantum_gates.py +setup.py +README.md +.pylintrc +``` + +The project is hosted here: + +[https://github.com/equs-python/two-qubit-simulator](https://github.com/equs-python/two-qubit-simulator) + +Start by making a local clone of the repository and create your own branch. Depending on what part of the project you decide to work on, give your branch a descripitve name. + +The plan is to divide the project into the following parts: + +- Write the `qubit_register.py` module + tests +- Write the `quantum_circuit.py` module + tests +- Write the `quantum_gates` module + tests +- Write documentation and usage examples +- Optional: write applications + +The `README.md` file contains information of how the individual modules are expected to work. Once you finished writing (and testing!) a piece of your code, make a pull request to the `master` branch. Any PR made to this branch will have to pass the automated tests and linting before it can be merged. We encourage all of you to review each others PRs. + + +## The `QubitRegister` class + +This class defines a quantum register consisting of one or two qubits. It should have the following attributes: + +**Attributes** + +- **state** \ No newline at end of file diff --git a/tests/test_circuits.py b/tests/test_circuits.py index b7d71d2..bb87ec9 100644 --- a/tests/test_circuits.py +++ b/tests/test_circuits.py @@ -2,4 +2,5 @@ Test the quantum_circuit module """ def test_quantum_circuit(): + #TODO pass diff --git a/tests/test_gates.py b/tests/test_gates.py index c411701..2208e42 100644 --- a/tests/test_gates.py +++ b/tests/test_gates.py @@ -2,4 +2,5 @@ Test the quantum_gate module """ def test_quantum_gate(): + #TODO pass diff --git a/tests/test_qubit_register.py b/tests/test_qubit_register.py index a4fe64e..7000047 100644 --- a/tests/test_qubit_register.py +++ b/tests/test_qubit_register.py @@ -2,4 +2,5 @@ Testing the qubit_register module """ def test_qubit_register(): + #TODO pass diff --git a/two_qubit_simulator/__init__.py b/two_qubit_simulator/__init__.py index 942b51f..efe1bea 100644 --- a/two_qubit_simulator/__init__.py +++ b/two_qubit_simulator/__init__.py @@ -2,3 +2,5 @@ Initialise the two_qubit_simulator module. Add import statements from auxilirary modules here. """ +#TODO + diff --git a/two_qubit_simulator/circuits.py b/two_qubit_simulator/circuits.py index aac385d..9f49362 100644 --- a/two_qubit_simulator/circuits.py +++ b/two_qubit_simulator/circuits.py @@ -9,16 +9,20 @@ class QuantumCircuit(object): # pylint: disable=useless-object-inheritance """ def __init__(self): """ Initialise a QuantumCircuit object """ + #TODO pass def add_gate(self, gate): """ Add a gate to the circuit """ + #TODO pass def run_circuit(self, register): """ Run the circuit on a given quantum register """ + #TODO pass def __call__(self, register): """ Run the circuit on a given quantum register """ + #TODO pass diff --git a/two_qubit_simulator/quantum_gates/__init__.py b/two_qubit_simulator/quantum_gates/__init__.py index 0889ec4..07d6dce 100644 --- a/two_qubit_simulator/quantum_gates/__init__.py +++ b/two_qubit_simulator/quantum_gates/__init__.py @@ -2,3 +2,4 @@ Initialise the quantum_gates module. Add import statements from auxilirary modules here. """ +#TODO diff --git a/two_qubit_simulator/quantum_gates/cnot.py b/two_qubit_simulator/quantum_gates/cnot.py index 7990a15..b49b2a6 100644 --- a/two_qubit_simulator/quantum_gates/cnot.py +++ b/two_qubit_simulator/quantum_gates/cnot.py @@ -6,5 +6,6 @@ class CNOT(QuantumGate): """ Implements the CNOT gate """ + #TODO pass diff --git a/two_qubit_simulator/quantum_gates/depolarising.py b/two_qubit_simulator/quantum_gates/depolarising.py index 22406b5..d50d06e 100644 --- a/two_qubit_simulator/quantum_gates/depolarising.py +++ b/two_qubit_simulator/quantum_gates/depolarising.py @@ -6,4 +6,5 @@ class Depolarising(QuantumGate): """ Implements the Depolarising gate """ + #TODO pass diff --git a/two_qubit_simulator/quantum_gates/hadamard.py b/two_qubit_simulator/quantum_gates/hadamard.py index 2dfcffc..e5f9486 100644 --- a/two_qubit_simulator/quantum_gates/hadamard.py +++ b/two_qubit_simulator/quantum_gates/hadamard.py @@ -6,4 +6,5 @@ class Hadamard(QuantumGate): """ Implements the Hadamard gate """ + #TODO pass diff --git a/two_qubit_simulator/quantum_gates/phase_gate.py b/two_qubit_simulator/quantum_gates/phase_gate.py index a15a1ad..5ce6f5b 100644 --- a/two_qubit_simulator/quantum_gates/phase_gate.py +++ b/two_qubit_simulator/quantum_gates/phase_gate.py @@ -6,4 +6,5 @@ class Phase(QuantumGate): """ Implements the Phase gate """ + #TODO pass diff --git a/two_qubit_simulator/quantum_gates/quantum_gate.py b/two_qubit_simulator/quantum_gates/quantum_gate.py index c15f811..26c2800 100644 --- a/two_qubit_simulator/quantum_gates/quantum_gate.py +++ b/two_qubit_simulator/quantum_gates/quantum_gate.py @@ -27,6 +27,7 @@ def __init__(self, unitary_operator, symbol=None): def assert_operation_is_unitary(self): """ Checks that the input unitary operator is unitary """ + #TODO pass def __call__(self, register): diff --git a/two_qubit_simulator/qubit_register.py b/two_qubit_simulator/qubit_register.py index cd670c4..56ab4b1 100644 --- a/two_qubit_simulator/qubit_register.py +++ b/two_qubit_simulator/qubit_register.py @@ -10,15 +10,18 @@ class QubitRegister(object): # pylint: disable=useless-object-inheritance def __init__(self, initial_state): """ Create a QubitRegister object """ + #TODO pass def apply_unitary(self, unitary): """ Apply a unitary state transformation on the qubit register """ + #TODO pass def measure(self, number_of_samples=1): """ Perform a measurement of the qubit register by sampling from a uniform probability distribution """ + #TODO pass From 82b1cad0e435f81adc83c97a1f542f2e745e7d68 Mon Sep 17 00:00:00 2001 From: Virginia Date: Tue, 29 Jan 2019 19:13:50 +1100 Subject: [PATCH 2/2] update readme --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b26c023..eea73dd 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,16 @@ This class defines a quantum register consisting of one or two qubits. It should **Attributes** -- **state** \ No newline at end of file +- **state** The qubit state, represented in whatever form you choose (e.g. density matrices) + + +## The `QuantumGate` class + +This class is an abstract class that defines the structure of a quantum gate. Your task is to derive classes from that which implement a quantum gate in the form of a unitary operator. + +**Attributes** + +- **unitary_operator** a Numpy array representing the operator +- **symbol** a string representing the gate (e.g. `'CNOT'` for a CNOT gate) + +