Skip to content

Commit 1b6f608

Browse files
Fix notebook tables (#1596)
This PR adds a new [Pandoc filter](https://github.com/jgm/pandocfilters/tree/master) to process the rst tables in the demos and convert them into Markdown for the notebooks. Conversion of the demos with tables has been tested locally. The demos with tables are: - ahs_aquila - tutorial_measurement_optimize - tutorial_neutral_atoms - tutorial_photonics - tutorial_quantum_transfer_learning - tutorial_unitary_synthesis_kak <img width="595" height="312" alt="Screenshot 2025-11-10 at 3 07 46 PM" src="https://github.com/user-attachments/assets/18279771-6fd0-4541-b75f-67395e280b36" /> <img width="557" height="249" alt="Screenshot 2025-11-10 at 3 07 57 PM" src="https://github.com/user-attachments/assets/61a02139-7d10-4721-9e73-ab0ee15b6dc6" /> Notes: - Handles figures, links, and math in tables and headers. - Handles (optional) table caption. - Handles Sphinx Gallery code execution outputs in a cleaner way. These are now added as a code block and the auto-generated Sphinx text (`sphx-glr-script-out`) is removed. - Two demos had HTML formatting set for the tables (which breaks the filter). I [tested removing this](https://pennylane.ai/qml/demonstrations?pr=1596) and it has no effect, since we do all the rendering on the website anyway. - The filter responsible for replacing images with URLs to the cloud-hosted version wasn't working. It is now fixed. - Some refactoring done to move a few things into a helper file for the filters.
1 parent 7132772 commit 1b6f608

File tree

15 files changed

+235
-86
lines changed

15 files changed

+235
-86
lines changed

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
"filters": [
8080
"./lib/filter_directives.py",
8181
"./lib/filter_figures.py",
82-
"./lib/filter_links.py"
82+
"./lib/filter_links.py",
83+
"./lib/filter_tables.py"
8384
]
8485
},
8586
# first notebook cell in generated Jupyter notebooks

demonstrations_v2/ahs_aquila/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": "2023-05-16T00:00:00+00:00",
11-
"dateOfLastModification": "2025-10-15T00:00:00+00:00",
11+
"dateOfLastModification": "2025-11-10T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Hardware",
1414
"Devices and Performance",
@@ -81,4 +81,4 @@
8181
"logo": "/_static/hardware_logos/aws.png"
8282
}
8383
]
84-
}
84+
}

demonstrations_v2/tutorial_measurement_optimize/demo.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,6 @@ def cost_circuit(params):
335335
# find the gates to rotate the circuit into the shared eigenbasis. To do so, we simply rotate
336336
# each qubit one-by-one depending on the Pauli operator we are measuring on that wire:
337337
#
338-
# .. raw:: html
339-
#
340-
# <style>
341-
# .docstable {
342-
# max-width: 300px;
343-
# }
344-
# .docstable tr.row-even th, .docstable tr.row-even td {
345-
# text-align: center;
346-
# }
347-
# .docstable tr.row-odd th, .docstable tr.row-odd td {
348-
# text-align: center;
349-
# }
350-
# </style>
351-
# <div class="d-flex justify-content-center">
352-
#
353338
# .. rst-class:: docstable
354339
#
355340
# +------------------+-------------------------------+
@@ -364,10 +349,6 @@ def cost_circuit(params):
364349
# | :math:`I` | :math:`I` |
365350
# +------------------+-------------------------------+
366351
#
367-
# .. raw:: html
368-
#
369-
# </div>
370-
#
371352
# Therefore, in this particular example:
372353
#
373354
# * Wire 0: we are measuring both terms in the :math:`X` basis, apply the Hadamard gate

demonstrations_v2/tutorial_measurement_optimize/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": true,
99
"executable_latest": true,
1010
"dateOfPublication": "2021-01-18T00:00:00+00:00",
11-
"dateOfLastModification": "2025-10-15T00:00:00+00:00",
11+
"dateOfLastModification": "2025-11-10T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Chemistry"
1414
],
@@ -96,4 +96,4 @@
9696
"weight": 1.0
9797
}
9898
]
99-
}
99+
}

demonstrations_v2/tutorial_neutral_atoms/demo.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -676,21 +676,6 @@ def neutral_atom_CZ(distance, coupling):
676676
#
677677
# The net effect of the sequence of pulses is summarized in the following table.
678678
#
679-
# .. raw:: html
680-
#
681-
# <style>
682-
# .docstable {
683-
# max-width: 300px;
684-
# }
685-
# .docstable tr.row-even th, .docstable tr.row-even td {
686-
# text-align: center;
687-
# }
688-
# .docstable tr.row-odd th, .docstable tr.row-odd td {
689-
# text-align: center;
690-
# }
691-
# </style>
692-
# <div class="d-flex justify-content-center">
693-
#
694679
# .. rst-class:: docstable
695680
#
696681
# +-------------------------+-------------------------------+
@@ -705,10 +690,6 @@ def neutral_atom_CZ(distance, coupling):
705690
# | :math:`\vert 11\rangle` | :math:`\vert 11\rangle` |
706691
# +-------------------------+-------------------------------+
707692
#
708-
# .. raw:: html
709-
#
710-
# </div>
711-
#
712693
# Up to a global phase, this corresponds to the :math:`CZ` gate. Together with the :math:`RX` and :math:`RY` gates, we have a universal set of gates,
713694
# since the `CNOT` gate can be expressed in terms of :math:`CZ` via the equation
714695
#

demonstrations_v2/tutorial_neutral_atoms/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": true,
99
"executable_latest": true,
1010
"dateOfPublication": "2023-05-30T00:00:00+00:00",
11-
"dateOfLastModification": "2025-10-15T00:00:00+00:00",
11+
"dateOfLastModification": "2025-11-10T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Hardware",
1414
"Quantum Computing"
@@ -134,4 +134,4 @@
134134
"weight": 1.0
135135
}
136136
]
137-
}
137+
}

demonstrations_v2/tutorial_photonics/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": true,
99
"executable_latest": true,
1010
"dateOfPublication": "2022-05-31T00:00:00+00:00",
11-
"dateOfLastModification": "2025-10-15T00:00:00+00:00",
11+
"dateOfLastModification": "2025-11-10T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Hardware",
1414
"Quantum Computing"
@@ -141,4 +141,4 @@
141141
}
142142
],
143143
"discussionForumUrl": "https://discuss.pennylane.ai/t/photonic-quantum-computers-demo/7335"
144-
}
144+
}

demonstrations_v2/tutorial_quantum_transfer_learning/demo.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@
6464
6565
.. rst-class:: docstable
6666
67-
+-----------+-----------+-----------------------------------------------------+
68-
| Network A | Network B | Transfer learning scheme |
69-
+===========+===========+=====================================================+
70-
| Classical | Classical | CC - Standard classical method. See e.g., Ref. [2]. |
71-
+-----------+-----------+-----------------------------------------------------+
72-
| Classical | Quantum | CQ - **Hybrid model presented in this tutorial.** |
73-
+-----------+-----------+-----------------------------------------------------+
74-
| Quantum | Classical | QC - Model studied in Ref. [1]. |
75-
+-----------+-----------+-----------------------------------------------------+
76-
| Quantum | Quantum | QQ - Model studied in Ref. [1]. |
77-
+-----------+-----------+-----------------------------------------------------+
67+
+-----------+-----------+-----------------------------------------------------+
68+
| Network A | Network B | Transfer learning scheme |
69+
+===========+===========+=====================================================+
70+
| Classical | Classical | CC - Standard classical method. See e.g., Ref. [2]. |
71+
+-----------+-----------+-----------------------------------------------------+
72+
| Classical | Quantum | CQ - **Hybrid model presented in this tutorial.** |
73+
+-----------+-----------+-----------------------------------------------------+
74+
| Quantum | Classical | QC - Model studied in Ref. [1]. |
75+
+-----------+-----------+-----------------------------------------------------+
76+
| Quantum | Quantum | QQ - Model studied in Ref. [1]. |
77+
+-----------+-----------+-----------------------------------------------------+
7878
7979
Classical-to-quantum transfer learning
8080
--------------------------------------

demonstrations_v2/tutorial_quantum_transfer_learning/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": true,
99
"executable_latest": true,
1010
"dateOfPublication": "2019-12-19T00:00:00+00:00",
11-
"dateOfLastModification": "2025-09-22T15:48:14+00:00",
11+
"dateOfLastModification": "2025-11-10T11:00:00+00:00",
1212
"categories": [
1313
"Quantum Machine Learning"
1414
],
@@ -63,4 +63,4 @@
6363
"referencedByPapers": [],
6464
"relatedContent": [],
6565
"discussionForumUrl": "https://discuss.pennylane.ai/t/can-quantum-transfer-learning-be-used-for-multi-classification/3963"
66-
}
66+
}

demonstrations_v2/tutorial_unitary_synthesis_kak/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"executable_stable": true,
99
"executable_latest": true,
1010
"dateOfPublication": "2025-05-30T09:00:00+00:00",
11-
"dateOfLastModification": "2025-09-22T15:48:14+00:00",
11+
"dateOfLastModification": "2025-11-10T00:00:00+00:00",
1212
"categories": [
1313
"Quantum Computing"
1414
],
@@ -118,4 +118,4 @@
118118
"weight": 1.0
119119
}
120120
]
121-
}
121+
}

0 commit comments

Comments
 (0)