Skip to content

Commit 9dee638

Browse files
Demo formatting fixes (#1597)
After merging the new Pandoc table filter, [two demos failed to build](https://github.com/PennyLaneAI/qml/actions/runs/19247842016/job/55026204946). In one case the figures were wrapped in an unnecessary extra directive, while in the other the Sphinx Gallery code blocks were not properly indented. This PR reformats those two demos so they will build correctly with the filters and produce valid Jupyter notebooks.
1 parent 1b6f608 commit 9dee638

File tree

4 files changed

+111
-113
lines changed

4 files changed

+111
-113
lines changed

demonstrations_v2/how_to_use_qiskit1_with_pennylane/demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ def qiskit_GHZ_circuit(n):
322322

323323

324324
######################################################################
325-
# .. rst-class:: image-no-text-wrap
326325
#
327326
# .. figure:: ../_static/demonstration_assets/how_to_use_qiskit_1_with_pennylane/qiskit_parameterized_circuit.png
328327
# :align: center
@@ -365,7 +364,6 @@ def differentiable_circuit(phis, theta):
365364
#
366365

367366
######################################################################
368-
# .. rst-class:: image-no-text-wrap
369367
#
370368
# .. figure:: ../_static/demonstration_assets/how_to_use_qiskit_1_with_pennylane/pl_real_world_example.png
371369
# :align: center
@@ -430,4 +428,4 @@ def cost(phis, theta):
430428
# the latest and greatest `PennyLane features </features/>`__, `Demos </qml/demonstrations/>`__ and our `blog posts </blog/>`__, and follow us on
431429
# `LinkedIn <https://www.linkedin.com/company/pennylaneai/>`__ or `X (formerly
432430
# Twitter) <https://twitter.com/PennyLaneAI>`__ to stay updated!
433-
#
431+
#

demonstrations_v2/how_to_use_qiskit1_with_pennylane/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": false,
99
"executable_latest": false,
1010
"dateOfPublication": "2024-07-02T00:00:00+00:00",
11-
"dateOfLastModification": "2025-10-15T00:00:00+00:00",
11+
"dateOfLastModification": "2025-11-11T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Computing",
1414
"How-to"
@@ -56,4 +56,4 @@
5656
"weight": 1.0
5757
}
5858
]
59-
}
59+
}

demonstrations_v2/linear_equations_hhl_qrisp_catalyst/demo.py

Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,24 @@ class inheritance. This simplification allows developers to focus on the algorit
7575
######################################################################
7676
# .. rst-class:: sphx-glr-script-out
7777
#
78-
# .. code-block:: none
79-
#
80-
# QuantumCircuit:
81-
# ---------------
82-
# ┌───┐┌───┐
83-
# qv_0.0: ┤ H ├┤ Z ├──■──
84-
# ├───┤└───┘ │
85-
# qv_0.1: ┤ Z ├───────┼──
86-
# ├───┤ │
87-
# qv_0.2: ┤ Z ├───────┼──
88-
# ├───┤ ┌─┴─┐
89-
# qv_0.3: ┤ Z ├─────┤ X ├
90-
# ├───┤ └───┘
91-
# qv_0.4: ┤ Z ├──────────
92-
# └───┘
93-
# Live QuantumVariables:
94-
# ----------------------
95-
# QuantumVariable qv_0
78+
# .. code-block:: none
79+
#
80+
# QuantumCircuit:
81+
# ---------------
82+
# ┌───┐┌───┐
83+
# qv_0.0: ┤ H ├┤ Z ├──■──
84+
# ├───┤└───┘ │
85+
# qv_0.1: ┤ Z ├───────┼──
86+
# ├───┤ │
87+
# qv_0.2: ┤ Z ├───────┼──
88+
# ├───┤ ┌─┴─┐
89+
# qv_0.3: ┤ Z ├─────┤ X ├
90+
# ├───┤ └───┘
91+
# qv_0.4: ┤ Z ├──────────
92+
# └───┘
93+
# Live QuantumVariables:
94+
# ----------------------
95+
# QuantumVariable qv_0
9696

9797
######################################################################
9898
# So far, this doesn’t seem that different from what you are used to, but it provides the
@@ -112,9 +112,9 @@ class inheritance. This simplification allows developers to focus on the algorit
112112
######################################################################
113113
# .. rst-class:: sphx-glr-script-out
114114
#
115-
# .. code-block:: none
115+
# .. code-block:: none
116116
#
117-
# {0.0: 0.125, 0.25: 0.125, 0.5: 0.125, 0.75: 0.125, 1.0: 0.125, 1.25: 0.125, 1.5: 0.125, 1.75: 0.125}
117+
# {0.0: 0.125, 0.25: 0.125, 0.5: 0.125, 0.75: 0.125, 1.0: 0.125, 1.25: 0.125, 1.5: 0.125, 1.75: 0.125}
118118

119119
######################################################################
120120
# Here, ``msize=3`` indicates the amount of mantissa qubits, which represent the significant digits of
@@ -154,12 +154,12 @@ class inheritance. This simplification allows developers to focus on the algorit
154154
######################################################################
155155
# .. rst-class:: sphx-glr-script-out
156156
#
157-
# .. code-block:: none
157+
# .. code-block:: none
158158
#
159-
# {7: 1.0}
160-
# {-2: 1.0}
161-
# {-4: 1.0}
162-
# {2.5: 1.0}
159+
# {7: 1.0}
160+
# {-2: 1.0}
161+
# {-4: 1.0}
162+
# {2.5: 1.0}
163163

164164
######################################################################
165165
# Another QuantumType we will use in this demo are the QuantumBools, representing boolean truth
@@ -174,9 +174,9 @@ class inheritance. This simplification allows developers to focus on the algorit
174174
######################################################################
175175
# .. rst-class:: sphx-glr-script-out
176176
#
177-
# .. code-block:: none
177+
# .. code-block:: none
178178
#
179-
# {False: 0.5, True: 0.5}
179+
# {False: 0.5, True: 0.5}
180180

181181
######################################################################
182182
# With a second QuantumBool, we can demonstrate and evaluate some logical functions:
@@ -190,11 +190,11 @@ class inheritance. This simplification allows developers to focus on the algorit
190190
######################################################################
191191
# .. rst-class:: sphx-glr-script-out
192192
#
193-
# .. code-block:: none
193+
# .. code-block:: none
194194
#
195-
# {False: 1.0}
196-
# {False: 0.5, True: 0.5}
197-
# {False: 1.0}
195+
# {False: 1.0}
196+
# {False: 0.5, True: 0.5}
197+
# {False: 1.0}
198198

199199
######################################################################
200200
# Comparisons, however, are not limited to only QuantumBools, but also for other types, like the
@@ -211,11 +211,11 @@ class inheritance. This simplification allows developers to focus on the algorit
211211
######################################################################
212212
# .. rst-class:: sphx-glr-script-out
213213
#
214-
# .. code-block:: none
214+
# .. code-block:: none
215215
#
216-
# {0: 0.5, 8: 0.5}
217-
# {False: 0.5, True: 0.5}
218-
# sqrt(2)*(|0>*|False> + |8>*|True>)/2
216+
# {0: 0.5, 8: 0.5}
217+
# {False: 0.5, True: 0.5}
218+
# sqrt(2)*(|0>*|False> + |8>*|True>)/2
219219

220220
######################################################################
221221
# We can also compare one QuantumFloat to another:
@@ -229,9 +229,9 @@ class inheritance. This simplification allows developers to focus on the algorit
229229
######################################################################
230230
# .. rst-class:: sphx-glr-script-out
231231
#
232-
# .. code-block:: none
232+
# .. code-block:: none
233233
#
234-
# sqrt(2)*(|0>*|False>*|4>*|True> + |8>*|True>*|4>*|False>)/2
234+
# sqrt(2)*(|0>*|False>*|4>*|True> + |8>*|True>*|4>*|False>)/2
235235

236236
######################################################################
237237
# Jasp
@@ -356,9 +356,9 @@ def U(psi):
356356
######################################################################
357357
# .. rst-class:: sphx-glr-script-out
358358
#
359-
# .. code-block:: none
359+
# .. code-block:: none
360360
#
361-
# {(0, 0.0): 0.25, (1, 0.5): 0.25, (2, 0.125): 0.25, (3, 0.625): 0.25}
361+
# {(0, 0.0): 0.25, (1, 0.5): 0.25, (2, 0.125): 0.25, (3, 0.625): 0.25}
362362

363363
######################################################################
364364
# Here, the measurement results are given by a dictionary, where the keys are are tuples representing
@@ -382,9 +382,9 @@ def main():
382382
######################################################################
383383
# .. rst-class:: sphx-glr-script-out
384384
#
385-
# .. code-block:: none
385+
# .. code-block:: none
386386
#
387-
# {0.625: 1.0}
387+
# {0.625: 1.0}
388388

389389
######################################################################
390390
# Executing the ``main`` function with the ``terminal_sampling`` decorator returns the measurement
@@ -506,9 +506,9 @@ def fake_inversion(qf, res=None):
506506
######################################################################
507507
# .. rst-class:: sphx-glr-script-out
508508
#
509-
# .. code-block:: none
509+
# .. code-block:: none
510510
#
511-
# {(0.125, 8): 0.3333333333333333, (0.25, 4): 0.3333333333333333, (0.5, 2): 0.3333333333333333}
511+
# {(0.125, 8): 0.3333333333333333, (0.25, 4): 0.3333333333333333, (0.5, 2): 0.3333333333333333}
512512

513513
######################################################################
514514
# Next, we define the function ``HHL_encoding`` that performs **Steps 1-4** and prepares the state
@@ -652,9 +652,9 @@ def main():
652652
######################################################################
653653
# .. rst-class:: sphx-glr-script-out
654654
#
655-
# .. code-block:: none
655+
# .. code-block:: none
656656
#
657-
# {0.0: 0.7071067811865476, 1.0: 0.7071067811865476}
657+
# {0.0: 0.7071067811865476, 1.0: 0.7071067811865476}
658658

659659
######################################################################
660660
# Finally, let’s compare to the classical result.
@@ -666,9 +666,9 @@ def main():
666666
######################################################################
667667
# .. rst-class:: sphx-glr-script-out
668668
#
669-
# .. code-block:: none
669+
# .. code-block:: none
670670
#
671-
# [0.70710678 0.70710678]
671+
# [0.70710678 0.70710678]
672672

673673
######################################################################
674674
# Et voila! Now, let’s tackle some more complicated examples! Next, we try some randomly generated
@@ -717,29 +717,29 @@ def U(qf):
717717
######################################################################
718718
# .. rst-class:: sphx-glr-script-out
719719
#
720-
# .. code-block:: none
721-
#
722-
# Hermitian matrix A:
723-
# [[ 0.19252221 0.03518761 -0.08725666 0.02288045 0.04538538 0.03247052
724-
# -0.06519315 -0.06229545]
725-
# [ 0.03518761 0.28758984 0.03595881 0.06702119 0.03489919 0.07145221
726-
# 0.07085617 -0.10555209]
727-
# [-0.08725666 0.03595881 0.28859598 0.00165777 -0.05503796 -0.03801707
728-
# 0.13179087 0.03443008]
729-
# [ 0.02288045 0.06702119 0.00165777 0.26810863 -0.12651043 0.00385685
730-
# -0.01492278 -0.10505962]
731-
# [ 0.04538538 0.03489919 -0.05503796 -0.12651043 0.34469893 0.07605711
732-
# 0.01253655 0.02660667]
733-
# [ 0.03247052 0.07145221 -0.03801707 0.00385685 0.07605711 0.31567327
734-
# 0.080171 -0.01770181]
735-
# [-0.06519315 0.07085617 0.13179087 -0.01492278 0.01253655 0.080171
736-
# 0.30119828 0.03446737]
737-
# [-0.06229545 -0.10555209 0.03443008 -0.10505962 0.02660667 -0.01770181
738-
# 0.03446737 0.25161286]]
739-
# Eigenvalues:
740-
# [0.25 0.5 0.5 0.125 0.125 0.5 0.125 0.125]
741-
# b:
742-
# [1 0 0 0 0 0 0 1]
720+
# .. code-block:: none
721+
#
722+
# Hermitian matrix A:
723+
# [[ 0.19252221 0.03518761 -0.08725666 0.02288045 0.04538538 0.03247052
724+
# -0.06519315 -0.06229545]
725+
# [ 0.03518761 0.28758984 0.03595881 0.06702119 0.03489919 0.07145221
726+
# 0.07085617 -0.10555209]
727+
# [-0.08725666 0.03595881 0.28859598 0.00165777 -0.05503796 -0.03801707
728+
# 0.13179087 0.03443008]
729+
# [ 0.02288045 0.06702119 0.00165777 0.26810863 -0.12651043 0.00385685
730+
# -0.01492278 -0.10505962]
731+
# [ 0.04538538 0.03489919 -0.05503796 -0.12651043 0.34469893 0.07605711
732+
# 0.01253655 0.02660667]
733+
# [ 0.03247052 0.07145221 -0.03801707 0.00385685 0.07605711 0.31567327
734+
# 0.080171 -0.01770181]
735+
# [-0.06519315 0.07085617 0.13179087 -0.01492278 0.01253655 0.080171
736+
# 0.30119828 0.03446737]
737+
# [-0.06229545 -0.10555209 0.03443008 -0.10505962 0.02660667 -0.01770181
738+
# 0.03446737 0.25161286]]
739+
# Eigenvalues:
740+
# [0.25 0.5 0.5 0.125 0.125 0.5 0.125 0.125]
741+
# b:
742+
# [1 0 0 0 0 0 0 1]
743743

744744

745745
@qrisp.terminal_sampling
@@ -758,10 +758,10 @@ def main():
758758
######################################################################
759759
# .. rst-class:: sphx-glr-script-out
760760
#
761-
# .. code-block:: none
761+
# .. code-block:: none
762762
#
763-
# array([0.73688311, 0.11916253, 0.09056467, 0.11650071, 0.09336856,
764-
# 0.04641304, 0.04607175, 0.63877596])
763+
# array([0.73688311, 0.11916253, 0.09056467, 0.11650071, 0.09336856,
764+
# 0.04641304, 0.04607175, 0.63877596])
765765

766766
######################################################################
767767
# Let’s compare to the classical solution:
@@ -773,10 +773,10 @@ def main():
773773
######################################################################
774774
# .. rst-class:: sphx-glr-script-out
775775
#
776-
# .. code-block:: none
776+
# .. code-block:: none
777777
#
778-
# [ 0.73761732 0.11838953 0.08853343 0.11632373 -0.09299411 -0.04581715
779-
# 0.04179596 0.63878104]
778+
# [ 0.73761732 0.11838953 0.08853343 0.11632373 -0.09299411 -0.04581715
779+
# 0.04179596 0.63878104]
780780

781781
######################################################################
782782
# First of all, kudos for making it to this point of the demo. Prior to proceeding to the final
@@ -848,34 +848,34 @@ def main():
848848
######################################################################
849849
# .. rst-class:: sphx-glr-script-out
850850
#
851-
# .. code-block:: none
852-
#
853-
# ; ModuleID = 'LLVMDialectModule'
854-
# source_filename = "LLVMDialectModule"
855-
# target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
856-
# target triple = "x86_64-unknown-linux-gnu"
857-
#
858-
# @"{'shots': 0, 'mcmc': False, 'num_burnin': 0, 'kernel_name': None}" = internal constant [66 x i8] c"{'shots': 0, 'mcmc': False, 'num_burnin': 0, 'kernel_name': None}\00"
859-
# @LightningSimulator = internal constant [19 x i8] c"LightningSimulator\00"
860-
# @"/home/positr0nium/miniforge3/envs/qrisp/lib/python3.10/site-packages/pennylane_lightning/liblightning_qubit_catalyst.so" = internal constant [120 x i8] c"/home/positr0nium/miniforge3/envs/qrisp/lib/python3.10/site-packages/pennylane_lightning/liblightning_qubit_catalyst.so\00"
861-
# @__constant_xi64_3 = private constant i64 -4
862-
# @__constant_1024xi64 = private constant [1024 x i64] zeroinitializer
863-
# @__constant_xi1 = private constant i1 false
864-
# @__constant_xi64_2 = private constant i64 4
865-
# @__constant_xi64_1 = private constant i64 3
866-
# @__constant_xi64_0 = private constant i64 30
867-
# @__constant_30xi64 = private constant [30 x i64] [i64 30, i64 29, i64 28, i64 27, i64 26, i64 25, i64 24, i64 23, i64 22, i64 21, i64 20, i64 19, i64 18, i64 17, i64 16, i64 15, i64 14, i64 13, i64 12, i64 11, i64 10, i64 9, i64 8, i64 7, i64 6, i64 5, i64 4, i64 3, i64 2, i64 1]
868-
# @__constant_xf64_34 = private constant double 0xBF919CF5D85DB47A
869-
# @__constant_xf64_33 = private constant double 0xBF89C4C2643A2DEA
870-
# @__constant_xf64_32 = private constant double 0xBF8696E980F4B09E
871-
# @__constant_xf64_31 = private constant double 0x3F69A6304F46D56B
872-
# @__constant_xf64_30 = private constant double 0xBF97F300BE6AA82E
873-
# @__constant_xf64_29 = private constant double 0x3F75120CFFA6C0C9
874-
# @__constant_xf64_28 = private constant double 0x3FA0EEDA934AC632
875-
# @__constant_xf64_27 = private constant double 0x3F9B793155FE33E5
876-
# @__constant_xf64_26 = private constant double 0x3EFEF5A8835D9B8E
877-
# @__constant_xf64_25 = private constant double 0xBF826D7D6D20BB88
878-
# @__constant_xf64_24 = private const
851+
# .. code-block:: none
852+
#
853+
# ; ModuleID = 'LLVMDialectModule'
854+
# source_filename = "LLVMDialectModule"
855+
# target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
856+
# target triple = "x86_64-unknown-linux-gnu"
857+
#
858+
# @"{'shots': 0, 'mcmc': False, 'num_burnin': 0, 'kernel_name': None}" = internal constant [66 x i8] c"{'shots': 0, 'mcmc': False, 'num_burnin': 0, 'kernel_name': None}\00"
859+
# @LightningSimulator = internal constant [19 x i8] c"LightningSimulator\00"
860+
# @"/home/positr0nium/miniforge3/envs/qrisp/lib/python3.10/site-packages/pennylane_lightning/liblightning_qubit_catalyst.so" = internal constant [120 x i8] c"/home/positr0nium/miniforge3/envs/qrisp/lib/python3.10/site-packages/pennylane_lightning/liblightning_qubit_catalyst.so\00"
861+
# @__constant_xi64_3 = private constant i64 -4
862+
# @__constant_1024xi64 = private constant [1024 x i64] zeroinitializer
863+
# @__constant_xi1 = private constant i1 false
864+
# @__constant_xi64_2 = private constant i64 4
865+
# @__constant_xi64_1 = private constant i64 3
866+
# @__constant_xi64_0 = private constant i64 30
867+
# @__constant_30xi64 = private constant [30 x i64] [i64 30, i64 29, i64 28, i64 27, i64 26, i64 25, i64 24, i64 23, i64 22, i64 21, i64 20, i64 19, i64 18, i64 17, i64 16, i64 15, i64 14, i64 13, i64 12, i64 11, i64 10, i64 9, i64 8, i64 7, i64 6, i64 5, i64 4, i64 3, i64 2, i64 1]
868+
# @__constant_xf64_34 = private constant double 0xBF919CF5D85DB47A
869+
# @__constant_xf64_33 = private constant double 0xBF89C4C2643A2DEA
870+
# @__constant_xf64_32 = private constant double 0xBF8696E980F4B09E
871+
# @__constant_xf64_31 = private constant double 0x3F69A6304F46D56B
872+
# @__constant_xf64_30 = private constant double 0xBF97F300BE6AA82E
873+
# @__constant_xf64_29 = private constant double 0x3F75120CFFA6C0C9
874+
# @__constant_xf64_28 = private constant double 0x3FA0EEDA934AC632
875+
# @__constant_xf64_27 = private constant double 0x3F9B793155FE33E5
876+
# @__constant_xf64_26 = private constant double 0x3EFEF5A8835D9B8E
877+
# @__constant_xf64_25 = private constant double 0xBF826D7D6D20BB88
878+
# @__constant_xf64_24 = private const
879879

880880
######################################################################
881881
# The Catalyst runtime
@@ -915,9 +915,9 @@ def main():
915915
######################################################################
916916
# .. rst-class:: sphx-glr-script-out
917917
#
918-
# .. code-block:: none
918+
# .. code-block:: none
919919
#
920-
# [1.0, 1.0, 0.0, 1.0, 0.0]
920+
# [1.0, 1.0, 0.0, 1.0, 0.0]
921921

922922
######################################################################
923923
# Scrolling back to the :ref:`terminal_sampling` cell, we see that the

demonstrations_v2/linear_equations_hhl_qrisp_catalyst/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"executable_stable": false,
1515
"executable_latest": false,
1616
"dateOfPublication": "2025-02-26T09:00:00+00:00",
17-
"dateOfLastModification": "2025-09-22T15:48:14+00:00",
17+
"dateOfLastModification": "2025-11-11T00:00:00+00:00",
1818
"categories": [
1919
"Algorithms",
2020
"Quantum Computing"
@@ -98,4 +98,4 @@
9898
"weight": 1.0
9999
}
100100
]
101-
}
101+
}

0 commit comments

Comments
 (0)