Skip to content

Commit 99e868e

Browse files
authored
add missing newlines to content blocks of gbs (#1394)
## Summary This PR adds some missing line breaks between reStructuredText sections of the [`gbs` demo](https://pennylane.ai/qml/demos/gbs). Also updates the hash lines to have consistent length of 79, as specified in the README. Currently, the lack of newline above some of the sections in this demo causes sphinx to incorrectly build the final HTML output. This results in partially or fully missing paragraphs in the final rendered page. This only affects a few of the sections of the `gbs` demo.
1 parent 4a74bee commit 99e868e

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

demonstrations/gbs.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"dateOfPublication": "2020-12-04T00:00:00+00:00",
12-
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
12+
"dateOfLastModification": "2025-06-02T00:00:00+00:00",
1313
"categories": [
1414
"Quantum Hardware",
1515
"Quantum Computing"

demonstrations/gbs.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
# import PennyLane
141141
import pennylane as qml
142142

143-
######################################################################
143+
##############################################################################
144144
# We must define the unitary matrix we would like to embed in the circuit.
145145
# We will use SciPy to generate a Haar-random unitary:
146146

@@ -188,7 +188,7 @@ def gbs_circuit():
188188
return qml.probs(wires=range(n_wires))
189189

190190

191-
######################################################################
191+
##############################################################################
192192
# A couple of things to note in this particular example:
193193
#
194194
# 1. To prepare the input single mode squeezed vacuum state :math:`|re^{i\phi}\rangle,`
@@ -222,7 +222,8 @@ def gbs_circuit():
222222
#
223223
# (10, 10, 10, 10)
224224
#
225-
######################################################################
225+
226+
##############################################################################
226227
# For example, element ``[1,2,0,1]`` represents the probability of
227228
# detecting 1 photon on wire
228229
# ``0`` and wire ``3``, and 2 photons at wire ``1``, i.e., the value
@@ -251,7 +252,8 @@ def gbs_circuit():
251252
# |1111>: 0.005957399165336106
252253
# |2000>: 0.02957384308320549
253254
#
254-
######################################################################
255+
256+
##############################################################################
255257
# The GBS Distribution
256258
# --------------------
257259
#
@@ -315,13 +317,13 @@ def gbs_circuit():
315317

316318
from thewalrus import hafnian as haf
317319

318-
######################################################################
320+
##############################################################################
319321
# Now, for the right-hand side numerator, we first calculate the submatrix
320322
# :math:`A = [(UU^T\mathrm{tanh}(r))]_{st}:`
321323

322324
A = np.dot(U, U.T) * np.tanh(1)
323325

324-
######################################################################
326+
##############################################################################
325327
# In GBS, we determine the submatrix by taking the
326328
# rows and columns corresponding to the measured Fock state. For example, to calculate the submatrix
327329
# in the case of the output measurement :math:`\left|{1,1,0,0}\right\rangle,`
@@ -338,11 +340,12 @@ def gbs_circuit():
338340
# [[ 0.19343159-0.54582922j 0.43418269-0.09169615j]
339341
# [ 0.43418269-0.09169615j -0.27554025-0.46222197j]]
340342
#
341-
######################################################################
343+
344+
##############################################################################
342345
# i.e., we consider only the rows and columns where a photon was detected, which gives us
343346
# the submatrix corresponding to indices :math:`0` and :math:`1.`
344347

345-
######################################################################
348+
##############################################################################
346349
# Comparing to simulation
347350
# -----------------------
348351
#
@@ -365,7 +368,8 @@ def gbs_circuit():
365368
# 0.1763784476141347
366369
# 0.17637844761413496
367370
#
368-
######################################################################
371+
372+
##############################################################################
369373
# **Measuring** :math:`|1,1,0,0\rangle` **at the output**
370374

371375
A = (np.dot(U, U.T) * np.tanh(1))[:, [0, 1]][[0, 1]]
@@ -381,7 +385,8 @@ def gbs_circuit():
381385
# 0.03473293649420271
382386
# 0.03473293649420282
383387
#
384-
######################################################################
388+
389+
##############################################################################
385390
# **Measuring** :math:`|0,1,0,1\rangle` **at the output**
386391

387392
A = (np.dot(U, U.T) * np.tanh(1))[:, [1, 3]][[1, 3]]
@@ -397,7 +402,8 @@ def gbs_circuit():
397402
# 0.011870900427255558
398403
# 0.011870900427255589
399404
#
400-
######################################################################
405+
406+
##############################################################################
401407
# **Measuring** :math:`|1,1,1,1\rangle` **at the output**
402408
#
403409
# This corresponds to the hafnian of the full matrix :math:`A=UU^T\mathrm{tanh}(r):`
@@ -415,7 +421,8 @@ def gbs_circuit():
415421
# 0.005957399165336081
416422
# 0.005957399165336106
417423
#
418-
######################################################################
424+
425+
##############################################################################
419426
# **Measuring** :math:`|2,0,0,0\rangle` **at the output**
420427
#
421428
# Since we have two photons in mode ``q[0]``, we take two copies of the

0 commit comments

Comments
 (0)