Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c211ab9

Browse filesBrowse files
committed
did some docstring editing
1 parent 6563c05 commit c211ab9
Copy full SHA for c211ab9

File tree

Expand file treeCollapse file tree

137 files changed

+739
-696
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

137 files changed

+739
-696
lines changed

‎qubiter/BitVector.py

Copy file name to clipboardExpand all lines: qubiter/BitVector.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def copy(bvec):
5757

5858
def bit_is_T(self, bpos):
5959
"""
60-
Returns True iff bit at position bpos is 1 (True)
60+
Returns True iff bit at position bpos is 1 (True).
6161
6262
Parameters
6363
----------
@@ -109,8 +109,8 @@ def set_bit_F(self, bpos):
109109

110110
def set_all_bits_T(self):
111111
"""
112-
Sets to 1 (True) the bits of self at position bpos
113-
from 0 to len-1 inclusive.
112+
Sets to 1 (True) the bits of self at position bpos from 0 to len-1
113+
inclusive.
114114
115115
Returns
116116
-------
@@ -122,8 +122,8 @@ def set_all_bits_T(self):
122122

123123
def set_all_bits_F(self):
124124
"""
125-
Sets to 0 (False) the bits of self at positions bpos
126-
from 0 to len-1 inclusive.
125+
Sets to 0 (False) the bits of self at positions bpos from 0 to len-1
126+
inclusive.
127127
128128
Returns
129129
-------
@@ -134,8 +134,8 @@ def set_all_bits_F(self):
134134

135135
def get_num_T_bits(self):
136136
"""
137-
Returns the number of 1 (True) bits at positions bpos
138-
from 0 to len-1 inclusive.
137+
Returns the number of 1 (True) bits at positions bpos from 0 to
138+
len-1 inclusive.
139139
140140
Returns
141141
-------
@@ -267,7 +267,7 @@ def get_bit_string(self):
267267

268268
def __str__(self):
269269
"""
270-
Readable representation of self
270+
Readable representation of self.
271271
272272
Returns
273273
-------

‎qubiter/CGateSEO_writer.py

Copy file name to clipboardExpand all lines: qubiter/CGateSEO_writer.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, file_prefix, emb,
7171
def su2_mat_prod(su2_pair1, su2_pair2):
7272
"""
7373
An SU(2) matrix can be expressed as exp(i*theta*sig_n) where theta
74-
is a real number and sig_n = n \cdot sigma. Here n is a 3 dim real
74+
is a real number and `sig_n = n \cdot sigma`. Here n is a 3 dim real
7575
UNIT vector and sigma = [sigx, sigy, sigz], where sigx, sigy and
7676
sigz are the 3 Pauli matrices. We define the su2_pair of this SU(2)
7777
matrix as the list [theta, n], with n expressed as a numpy array.
@@ -447,8 +447,8 @@ def write_cnot_stair(bvec):
447447
def write_hads(self, trol_kinds, herm_conj=False):
448448
"""
449449
Writes a chain of cnots that are useful when some of the controls of
450-
the c_u2 being considered are n_bar = P_0 = |0><0| instead of n =
451-
P_1 = |1><1|. We are using the identity sigx n sigx = nbar to
450+
the c_u2 being considered are `n_bar = P_0 = |0><0|` instead of `n =
451+
P_1 = |1><1|`. We are using the identity sigx n sigx = nbar to
452452
convert n's to nbar's.
453453
454454
Parameters

‎qubiter/CktEmbedder.py

Copy file name to clipboardExpand all lines: qubiter/CktEmbedder.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, num_qbits_bef, num_qbits_aft, bit_map=None):
4545

4646
def get_num_new_bits(self):
4747
"""
48-
Returns num_qbits_aft - num_qbits_bef
48+
Returns num_qbits_aft - num_qbits_bef.
4949
5050
Returns
5151
-------
@@ -56,7 +56,7 @@ def get_num_new_bits(self):
5656

5757
def is_identity_map(self):
5858
"""
59-
Returns True (False) if bit_map is None (list)
59+
Returns True (False) if bit_map is None (list).
6060
6161
Returns
6262
-------
@@ -67,8 +67,8 @@ def is_identity_map(self):
6767

6868
def aft(self, bef):
6969
"""
70-
Returns bit_map[bef] if bit_map is list. If bit_map
71-
is None, returns input 'bef' untouched.
70+
Returns bit_map[bef] if bit_map is list. If bit_map is None, returns
71+
input 'bef' untouched.
7272
7373
Parameters
7474
----------

‎qubiter/Controls.py

Copy file name to clipboardExpand all lines: qubiter/Controls.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Controls:
77
This class stores a dictionary called self.bit_pos_to_kind containing
88
key-value pairs of the form (a control's qubit number: its kind). Kinds
99
can be either a bool or a non-negative integer. Kind is True if control
10-
is P_1 = n = |1><1|. Kind is False if control is P_0 = nbar = |0><0|.
10+
is `P_1 = n = |1><1|`. Kind is False if control is `P_0 = nbar = |0><0|`.
1111
Kind is a non-negative integer for MP_Y and DIAG controls.
1212
1313
Attributes
@@ -73,7 +73,7 @@ def copy(old, extra_bits=0):
7373

7474
def set_control(self, bit_pos, kind, do_refresh=False):
7575
"""
76-
Add key-value pair (bit_pos: kind) to self.bit_pos_to_kind dictionary
76+
Add key-value pair (bit_pos: kind) to self.bit_pos_to_kind dictionary.
7777
7878
Parameters
7979
----------
@@ -115,7 +115,7 @@ def refresh_lists(self):
115115
@staticmethod
116116
def new_single_trol(num_qbits, bit_pos, kind):
117117
"""
118-
Returns a single control
118+
Returns a single control.
119119
120120
Parameters
121121
----------

‎qubiter/FouSEO_writer.py

Copy file name to clipboardExpand all lines: qubiter/FouSEO_writer.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def write(self):
7171

7272
def write_hermitian(self):
7373
"""
74-
Write Hermitian conjugate of circuit written by write()
74+
Write Hermitian conjugate of circuit written by write().
7575
7676
Returns
7777
-------

‎qubiter/LoopFileGenerator.py

Copy file name to clipboardExpand all lines: qubiter/LoopFileGenerator.py
+20-16Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,29 @@ def main():
136136
OneQubitGate.rot_ax,
137137
['#1', 1])
138138
wr.write_LOOP(20, nreps=2)
139-
wr.write_controlled_one_qbit_gate(1,
140-
Controls.new_single_trol(num_qbits, 2, False),
141-
OneQubitGate.rot_ax,
142-
['-my_fun1#1#2', 2])
139+
wr.write_controlled_one_qbit_gate(
140+
1,
141+
Controls.new_single_trol(num_qbits, 2, False),
142+
OneQubitGate.rot_ax,
143+
['-my_fun1#1#2', 2])
143144
wr.write_LOOP(10, nreps=4)
144-
wr.write_controlled_one_qbit_gate(2,
145-
Controls.new_single_trol(num_qbits, 3, True),
146-
OneQubitGate.rot,
147-
['-#1*.5', '#2', '-my_fun3#3'])
145+
wr.write_controlled_one_qbit_gate(
146+
2,
147+
Controls.new_single_trol(num_qbits, 3, True),
148+
OneQubitGate.rot,
149+
['-#1*.5', '#2', '-my_fun3#3'])
148150
wr.write_NEXT(10)
149-
wr.write_controlled_one_qbit_gate(1,
150-
Controls.new_single_trol(num_qbits, 2, False),
151-
OneQubitGate.rot_ax,
152-
['my_fun1#1#2', 2])
151+
wr.write_controlled_one_qbit_gate(
152+
1,
153+
Controls.new_single_trol(num_qbits, 2, False),
154+
OneQubitGate.rot_ax,
155+
['my_fun1#1#2', 2])
153156
wr.write_NEXT(20)
154-
wr.write_controlled_one_qbit_gate(0,
155-
Controls.new_single_trol(num_qbits, 2, False),
156-
OneQubitGate.rot_ax,
157-
['#1*.3', 1])
157+
wr.write_controlled_one_qbit_gate(
158+
0,
159+
Controls.new_single_trol(num_qbits, 2, False),
160+
OneQubitGate.rot_ax,
161+
['#1*.3', 1])
158162
wr.write_one_qbit_gate(1, OneQubitGate.rot_ax, ['my_fun#1', 1])
159163
wr.close_files()
160164

‎qubiter/OneQubitGate.py

Copy file name to clipboardExpand all lines: qubiter/OneQubitGate.py
+14-13Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_fun(lib, fun_name, lib_to_fun_name=None):
111111
@staticmethod
112112
def had2(is_quantum=True, lib='np'):
113113
"""
114-
Returns 2 dimensional Hadamard matrix (\sigma_x + \sigma_z)/sqrt(2)
114+
Returns 2 dimensional Hadamard matrix (sigma_x + sigma_z)/sqrt(2).
115115
116116
Parameters
117117
----------
@@ -135,8 +135,8 @@ def had2(is_quantum=True, lib='np'):
135135
@staticmethod
136136
def P_0(is_quantum=True, lib='np'):
137137
"""
138-
Returns projection operator P_0 = |0><0| = nbar, where |0> = [1,
139-
0]^T and |1> = [0, 1]^T, T = transpose
138+
Returns projection operator `P_0 = |0><0| = nbar`, where `|0> = [1,
139+
0]^T` and `|1> = [0, 1]^T`, T = transpose
140140
141141
Parameters
142142
----------
@@ -159,8 +159,8 @@ def P_0(is_quantum=True, lib='np'):
159159
@staticmethod
160160
def P_1(is_quantum=True, lib='np'):
161161
"""
162-
Returns projection operator P_1 = |1><1| = n, where |0> = [1,
163-
0]^T and |1> = [0, 1]^T, T = transpose
162+
Returns projection operator `P_1 = |1><1| = n`, where `|0> = [1,
163+
0]^T` and `|1> = [0, 1]^T`, T = transpose
164164
165165
Parameters
166166
----------
@@ -292,7 +292,8 @@ def rot(rad_ang_x, rad_ang_y, rad_ang_z, lib='np'):
292292

293293
mat_dict = OneQubitGate.const_dict(0)
294294
vec = [rad_ang_x, rad_ang_y, rad_ang_z]
295-
n = OneQubitGate.get_fun(lib, 'sqrt')(vec[0]**2 + vec[1]**2 + vec[2]**2)
295+
n = OneQubitGate.get_fun(lib, 'sqrt')(
296+
vec[0]**2 + vec[1]**2 + vec[2]**2)
296297
if abs(n) < 1e-8:
297298
mat_dict['00'] = 1
298299
mat_dict['11'] = 1
@@ -360,7 +361,7 @@ def rot_ax(rad_ang, axis, lib='np'):
360361
@staticmethod
361362
def sigx(is_quantum=True, lib='np'):
362363
"""
363-
Returns \sigma_x Pauli matrix.
364+
Returns sigma_x Pauli matrix.
364365
365366
Parameters
366367
----------
@@ -384,7 +385,7 @@ def sigx(is_quantum=True, lib='np'):
384385
@staticmethod
385386
def sigy(lib='np'):
386387
"""
387-
Returns \sigma_y Pauli matrix.
388+
Returns sigma_y Pauli matrix.
388389
389390
Parameters
390391
----------
@@ -403,7 +404,7 @@ def sigy(lib='np'):
403404
@staticmethod
404405
def sigz(is_quantum=True, lib='np'):
405406
"""
406-
Returns \sigma_z Pauli matrix.
407+
Returns sigma_z Pauli matrix.
407408
408409
Parameters
409410
----------
@@ -431,7 +432,7 @@ def mat_S(herm=False, lib='np'):
431432
432433
[[1, 0],[0, x*sign]] where x=exp(j*pi/2)=j
433434
434-
where sign = 1 if herm=False and sign = -1 if herm=True
435+
where sign = 1 if herm=False and sign = -1 if herm=True.
435436
436437
Parameters
437438
----------
@@ -452,7 +453,7 @@ def mat_S(herm=False, lib='np'):
452453
@staticmethod
453454
def mat_Sdag(lib='np'):
454455
"""
455-
returns S^\dag
456+
returns `S^\dag`.
456457
457458
Parameters
458459
----------
@@ -472,7 +473,7 @@ def mat_T(herm=False, lib='np'):
472473
473474
[[1, 0],[0, exp(j*pi/4*sign)]]
474475
475-
where sign = 1 if herm=False and sign = -1 if herm=True
476+
where sign = 1 if herm=False and sign = -1 if herm=True.
476477
477478
Parameters
478479
----------
@@ -493,7 +494,7 @@ def mat_T(herm=False, lib='np'):
493494
@staticmethod
494495
def mat_Tdag(lib='np'):
495496
"""
496-
returns T^\dag
497+
returns `T^\dag`.
497498
498499
Parameters
499500
----------

‎qubiter/Plotter.py

Copy file name to clipboardExpand all lines: qubiter/Plotter.py
+23-23Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,29 @@ def plot_probs_col(titles, probs_col_df_list):
168168
num_titles = len(titles)
169169

170170
def single_pd(ax, title, pd_df):
171-
y_pos = np.arange(len(pd_df.index)) + .5
172-
plt.sca(ax)
173-
plt.yticks(y_pos, pd_df.index)
174-
ax.invert_yaxis()
175-
176-
ax.set_xticks([0, .25, .5, .75, 1])
177-
ax.set_xlim(0, 1)
178-
179-
for row in range(len(y_pos)):
180-
val = pd_df.values[row]
181-
if isinstance(val, np.ndarray):
182-
val = val[0]
183-
ax.text(val, y_pos[row], '{:.3f}'.format(val))
184-
185-
ax.grid(True)
186-
ax.set_title(title)
187-
# new version of python/matplotlib has bug here.
188-
# The following used to work but no longer does.
189-
# ax.barh(y_pos, pd_df.values, align='center')
190-
# work around
191-
for b in range(len(y_pos)):
192-
ax.barh(y_pos[b], pd_df.values[b],
193-
align='center', color='blue')
171+
y_pos = np.arange(len(pd_df.index)) + .5
172+
plt.sca(ax)
173+
plt.yticks(y_pos, pd_df.index)
174+
ax.invert_yaxis()
175+
176+
ax.set_xticks([0, .25, .5, .75, 1])
177+
ax.set_xlim(0, 1)
178+
179+
for row in range(len(y_pos)):
180+
val = pd_df.values[row]
181+
if isinstance(val, np.ndarray):
182+
val = val[0]
183+
ax.text(val, y_pos[row], '{:.3f}'.format(val))
184+
185+
ax.grid(True)
186+
ax.set_title(title)
187+
# new version of python/matplotlib has bug here.
188+
# The following used to work but no longer does.
189+
# ax.barh(y_pos, pd_df.values, align='center')
190+
# work around
191+
for b in range(len(y_pos)):
192+
ax.barh(y_pos[b], pd_df.values[b],
193+
align='center', color='blue')
194194
plt.close('all')
195195
fig, ax_list = plt.subplots(nrows=num_titles, ncols=1)
196196
# print("***", ax_list[0])

‎qubiter/SEO_Lista.py

Copy file name to clipboardExpand all lines: qubiter/SEO_Lista.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def simulate(self, **kwargs1):
224224

225225
def print(self):
226226
"""
227-
prints self.line_list, one item per line
227+
Prints self.line_list, one item per line.
228228
229229
Returns
230230
-------
@@ -264,7 +264,7 @@ def get_var_nums_and_fun_names(self):
264264

265265
def __add__(self, other):
266266
"""
267-
define + of two SEO_Lista objects
267+
Define + of two SEO_Lista objects.
268268
269269
Parameters
270270
----------
@@ -281,7 +281,7 @@ def __add__(self, other):
281281

282282
def __iadd__(self, other):
283283
"""
284-
define += for inplace addition of an SEO_Lista object to self
284+
Define += for inplace addition of an SEO_Lista object to self.
285285
286286
Parameters
287287
----------
@@ -298,7 +298,7 @@ def __iadd__(self, other):
298298

299299
def __getitem__(self, item):
300300
"""
301-
define self[item]
301+
Define self[item].
302302
303303
Parameters
304304
----------

‎qubiter/SEO_MatrixProduct.py

Copy file name to clipboardExpand all lines: qubiter/SEO_MatrixProduct.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def use_MEAS(self, tar_bit_pos, kind):
3232

3333
def use_PRINT(self, style, line_num):
3434
"""
35-
If circuit has any PRINT statements, skip them
35+
If circuit has any PRINT statements, skip them.
3636
3737
Parameters
3838
----------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.