Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
# `__equs.Python__` workshop 2019 - Coding project
# `__equs.Python__` workshop 2019 - Code project


**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** 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)


Details to follow ...
1 change: 1 addition & 0 deletions tests/test_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Test the quantum_circuit module
"""
def test_quantum_circuit():
#TODO
pass
1 change: 1 addition & 0 deletions tests/test_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Test the quantum_gate module
"""
def test_quantum_gate():
#TODO
pass
1 change: 1 addition & 0 deletions tests/test_qubit_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Testing the qubit_register module
"""
def test_qubit_register():
#TODO
pass
2 changes: 2 additions & 0 deletions two_qubit_simulator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
Initialise the two_qubit_simulator module.
Add import statements from auxilirary modules here.
"""
#TODO

4 changes: 4 additions & 0 deletions two_qubit_simulator/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Initialise the quantum_gates module.
Add import statements from auxilirary modules here.
"""
#TODO
1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/cnot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

class CNOT(QuantumGate):
""" Implements the CNOT gate """
#TODO
pass

1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/depolarising.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

class Depolarising(QuantumGate):
""" Implements the Depolarising gate """
#TODO
pass
1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/hadamard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

class Hadamard(QuantumGate):
""" Implements the Hadamard gate """
#TODO
pass
1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/phase_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

class Phase(QuantumGate):
""" Implements the Phase gate """
#TODO
pass
1 change: 1 addition & 0 deletions two_qubit_simulator/quantum_gates/quantum_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions two_qubit_simulator/qubit_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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