Skip to content

Commit 86966af

Browse files
committed
Update documentation of the simulaqron.virtual_node package
1 parent ab1f263 commit 86966af

File tree

9 files changed

+690
-339
lines changed

9 files changed

+690
-339
lines changed

docs/simulaqron.toolbox.rst

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,6 @@ simulaqron.toolbox package
44
Submodules
55
----------
66

7-
simulaqron.toolbox.get_simulaqron_path module
8-
---------------------------------------------
9-
10-
.. automodule:: simulaqron.toolbox.get_simulaqron_path
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
14-
15-
simulaqron.toolbox.has_module module
16-
------------------------------------
17-
18-
.. automodule:: simulaqron.toolbox.has_module
19-
:members:
20-
:undoc-members:
21-
:show-inheritance:
22-
23-
simulaqron.toolbox.manage_nodes module
24-
--------------------------------------
25-
26-
.. automodule:: simulaqron.toolbox.manage_nodes
27-
:members:
28-
:undoc-members:
29-
:show-inheritance:
30-
31-
simulaqron.toolbox.reset module
32-
-------------------------------
33-
34-
.. automodule:: simulaqron.toolbox.reset
35-
:members:
36-
:undoc-members:
37-
:show-inheritance:
38-
397
simulaqron.toolbox.stabilizer_states module
408
-------------------------------------------
419

docs/simulaqron.virtual_node.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ simulaqron.virtual_node.qutip_simulator module
3636
:undoc-members:
3737
:show-inheritance:
3838

39-
simulaqron.virtual_node.stabilizerSimulator module
39+
simulaqron.virtual_node.stabilizer_simulator module
4040
--------------------------------------------------
4141

4242
.. automodule:: simulaqron.virtual_node.stabilizer_simulator

simulaqron/toolbox/stabilizer_states.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class StabilizerState:
2323

2424
Pauli2bool = {"I": (False, False), "X": (True, False), "Y": (True, True), "Z": (False, True)}
2525

26-
def __init__(self, data=None, check_symplectic=True):
26+
def __init__(self, data=None, check_symplectic: bool = True):
2727
"""
2828
This class represent a stabilizer state and allows to be manipulated using
2929
Clifford operations and Pauli-measurements.
@@ -82,8 +82,8 @@ def __init__(self, data=None, check_symplectic=True):
8282
The entangled state (|01> + |10>)/sqrt(2) can be created as:
8383
StabilizerState([[1, 1, 0, 0, 0],
8484
0, 0, 1, 1, 1]])
85-
:param check_symplectic: bool
86-
Whether to check if all stabilizers commute or not.
85+
:param check_symplectic: Whether to check if all stabilizers commute or not.
86+
:type check_symplectic: bool
8787
"""
8888
if data is None:
8989
self._group = np.empty(shape=(0, 0), dtype=bool)
@@ -265,6 +265,7 @@ def boolean_gaussian_elimination(matrix, return_pivot_columns=False):
265265
"""
266266
Given a boolean matrix returns the matrix in row reduced echelon form
267267
where entries are seen as elements of GF(2), i.e. intergers modulus 2.
268+
268269
:param matrix: The boolean matrix
269270
:type matrix: :obj:`numpy.array`
270271
:return:

simulaqron/virtual_node/basics.py

Lines changed: 83 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ def __str__(self):
5555
class QuantumEngine(pb.Referenceable, abc.ABC):
5656
"""
5757
Basic quantum engine. Abstract class meant to be subclassed to implement different simulation backends.
58-
59-
Attributes:
60-
Arguments
61-
node node this register is started from
62-
num number of this register
63-
maxQubits maximum number of qubits this register supports
6458
"""
6559

6660
def __init__(self, node: str, num: int, maxQubits: int = 10):
6761
"""
68-
Initialize the simple engine. If no number is given for maxQubits, the assumption will be 10.
62+
Initialize the simple engine.
63+
64+
:param node: Node name this register is started from.
65+
:type node: str
66+
:param num: Number of this register.
67+
:type num: int
68+
:param maxQubits: maximum number of qubits this register supports. If not give, it will default to 10.
69+
:type maxQubits: int
6970
"""
7071

7172
self.maxQubits = maxQubits
@@ -80,7 +81,8 @@ def __init__(self, node: str, num: int, maxQubits: int = 10):
8081
@abc.abstractmethod
8182
def add_fresh_qubit(self) -> int:
8283
"""
83-
Add a new qubit initialized in the |0> state.
84+
Add a new qubit initialized in the :math:`|0>` state.
85+
8486
:return: The qubit number
8587
:rtype: int
8688
"""
@@ -90,6 +92,9 @@ def add_fresh_qubit(self) -> int:
9092
def add_qubit(self, newQubit) -> int:
9193
"""
9294
Add new qubit in the state described by the density matrix newQubit
95+
96+
:param newQubit: The new qubit state
97+
:type newQubit: Any
9398
:return: The qubit number
9499
:rtype: int
95100
"""
@@ -99,6 +104,9 @@ def add_qubit(self, newQubit) -> int:
99104
def remove_qubit(self, qubitNum: int) -> None:
100105
"""
101106
Removes the qubit with the desired number qubitNum
107+
108+
:param qubitNum: Qubit number
109+
:type qubitNum: int
102110
:rtype: None
103111
"""
104112
pass
@@ -117,8 +125,9 @@ def get_register_RI(self):
117125
def get_density_matrix_RI(self):
118126
"""
119127
Retrieves the entire register in real and imaginary parts and returns the result of
120-
the outer product. In other words, if the qubit is in state |q>, this function
121-
returns the density matrix |q><q| of the qubit.
128+
the outer product. In other words, if the qubit is in state :math:`|q>`, this function
129+
returns the density matrix :math:`|q><q|` of the qubit.
130+
122131
:return: The density matrix real and imaginary parts of a qubit state
123132
"""
124133
pass
@@ -127,6 +136,9 @@ def get_density_matrix_RI(self):
127136
def apply_H(self, qubitNum):
128137
"""
129138
Applies a Hadamard gate to the qubits with number qubitNum.
139+
140+
:param qubitNum: Qubit number
141+
:type qubitNum: int
130142
:rtype: None
131143
"""
132144
pass
@@ -135,14 +147,20 @@ def apply_H(self, qubitNum):
135147
def apply_K(self, qubitNum):
136148
"""
137149
Applies a K gate to the qubits with number qubitNum. Maps computational basis to Y eigenbasis.
150+
151+
:param qubitNum: Qubit number
152+
:type qubitNum: int
138153
:rtype: None
139154
"""
140155
pass
141156

142157
@abc.abstractmethod
143158
def apply_X(self, qubitNum):
144159
"""
145-
Applies a X gate to the qubits with number qubitNum.
160+
Applies an X gate to the qubits with number qubitNum.
161+
162+
:param qubitNum: Qubit number
163+
:type qubitNum: int
146164
:rtype: None
147165
"""
148166
pass
@@ -151,6 +169,9 @@ def apply_X(self, qubitNum):
151169
def apply_Z(self, qubitNum):
152170
"""
153171
Applies a Z gate to the qubits with number qubitNum.
172+
173+
:param qubitNum: Qubit number
174+
:type qubitNum: int
154175
:rtype: None
155176
"""
156177
pass
@@ -159,6 +180,9 @@ def apply_Z(self, qubitNum):
159180
def apply_Y(self, qubitNum):
160181
"""
161182
Applies a Y gate to the qubits with number qubitNum.
183+
184+
:param qubitNum: Qubit number
185+
:type qubitNum: int
162186
:rtype: None
163187
"""
164188
pass
@@ -167,6 +191,9 @@ def apply_Y(self, qubitNum):
167191
def apply_T(self, qubitNum):
168192
"""
169193
Applies a T gate to the qubits with number qubitNum.
194+
195+
:param qubitNum: Qubit number
196+
:type qubitNum: int
170197
:rtype: None
171198
"""
172199
pass
@@ -177,12 +204,12 @@ def apply_rotation(self, qubitNum, n, a):
177204
Applies a rotation around the axis n with the angle a to qubit with number qubitNum. If n is zero a ValueError
178205
is raised.
179206
180-
:param qubitNum: int
181-
Qubit number
182-
:param n: tuple
183-
A tuple of three numbers specifying the rotation axis, e.g n=(1,0,0)
184-
:param a: float
185-
The rotation angle in radians.
207+
:param qubitNum: Qubit number
208+
:type qubitNum: int
209+
:param n: A tuple of three numbers specifying the rotation axis, e.g n=(1,0,0)
210+
:type n: Tuple[int, int, int]
211+
:param a: The rotation angle in radians.
212+
:type a: float
186213
:rtype: None
187214
"""
188215
pass
@@ -191,6 +218,11 @@ def apply_rotation(self, qubitNum, n, a):
191218
def apply_CNOT(self, qubitNum1, qubitNum2):
192219
"""
193220
Applies the CNOT to the qubit with the numbers qubitNum1 and qubitNum2.
221+
222+
:param qubitNum1: Qubit number 1
223+
:type qubitNum1: int
224+
:param qubitNum2: Qubit number 2
225+
:type qubitNum2: int
194226
:rtype: None
195227
"""
196228
pass
@@ -199,6 +231,11 @@ def apply_CNOT(self, qubitNum1, qubitNum2):
199231
def apply_CPHASE(self, qubitNum1, qubitNum2):
200232
"""
201233
Applies the CPHASE to the qubit with the numbers qubitNum1 and qubitNum2.
234+
235+
:param qubitNum1: Qubit number 1
236+
:type qubitNum1: int
237+
:param qubitNum2: Qubit number 2
238+
:type qubitNum2: int
202239
:rtype: None
203240
"""
204241
pass
@@ -208,9 +245,10 @@ def apply_onequbit_gate(self, gateU, qubitNum):
208245
"""
209246
Applies a unitary gate to the specified qubit.
210247
211-
Arguments:
212-
gateU unitary to apply as Qobj
213-
qubitNum the number of the qubit this gate is applied to
248+
:param gateU: Unitary to apply as Qobj
249+
:type gateU: Qobj
250+
:param qubitNum: The number of the qubit this gate is applied to
251+
:type qubitNum: int
214252
:rtype: None
215253
"""
216254
pass
@@ -220,10 +258,12 @@ def apply_twoqubit_gate(self, gateU, qubit1, qubit2):
220258
"""
221259
Applies a unitary gate to the two specified qubits.
222260
223-
Arguments:
224-
gateU unitary to apply as Qobj
225-
qubit1 the first qubit
226-
qubit2 the second qubit
261+
:param gateU: Unitary to apply as Qobj
262+
:type gateU: Qobj
263+
:param qubit1: The first qubit
264+
:type qubit1: int
265+
:param qubit2: The second qubit
266+
:type qubit2: int
227267
:rtype: None
228268
"""
229269
pass
@@ -234,9 +274,9 @@ def measure_qubit_inplace(self, qubitNum):
234274
Measures the desired qubit in the standard basis. This returns the classical outcome. The quantum register
235275
is in the post-measurment state corresponding to the obtained outcome.
236276
237-
Arguments:
238-
qubitNum qubit to be measured
239-
:return: The meaurement outcome
277+
:param qubitNum: Qubit to be measured
278+
:type qubitNum: int
279+
:return: The measurement outcome
240280
:rtype: int
241281
"""
242282
pass
@@ -246,9 +286,9 @@ def measure_qubit(self, qubitNum):
246286
"""
247287
Measures the desired qubit in the standard basis. This returns the classical outcome and deletes the qubit.
248288
249-
Arguments:
250-
qubitNum qubit to be measured
251-
:return: The meaurement outcome
289+
:param qubitNum: Qubit to be measured
290+
:type qubitNum: int
291+
:return: The measurement outcome
252292
:rtype: int
253293
"""
254294
pass
@@ -257,6 +297,11 @@ def measure_qubit(self, qubitNum):
257297
def replace_qubit(self, qubitNum, state):
258298
"""
259299
Replaces the qubit at position qubitNum with the one given by state.
300+
301+
:param qubitNum: Qubit to be replaced
302+
:type qubitNum: int
303+
:param state: New state to write in the place of the old qubit.
304+
:type state: Any
260305
:rtype: None
261306
"""
262307
pass
@@ -265,6 +310,9 @@ def replace_qubit(self, qubitNum, state):
265310
def absorb(self, other):
266311
"""
267312
Absorb the qubits from the other engine into this one. This is done by tensoring the state at the end.
313+
314+
:param other: The other qubit to absorb.
315+
:type other: int
268316
:rtype: None
269317
"""
270318
pass
@@ -274,10 +322,11 @@ def absorb_parts(self, R, I, activeQ):
274322
"""
275323
Absorb the qubits, given in pieces
276324
277-
Arguments:
278-
R real part of the qubit state as a list
279-
I imaginary part as a list
280-
activeQ active number of qubits
325+
:param R: Real part of the qubit state as a list.
326+
:type R: List[float]
327+
:param I: Imaginary part as a list.
328+
:type I: List[float]
329+
:param activeQ: Active number of qubits
281330
:rtype: None
282331
"""
283332
pass

0 commit comments

Comments
 (0)