Skip to content

Commit 537ae84

Browse files
committed
_generate_notebooks: deterministic cell ids + ruff-clean triple quotes
- Cell ids are now derived from ``sha1(nb_filename + idx)``. Without this, nbformat ≥ 4.5 assigns fresh random ids on every write, so every re-run of the generator produced a large diff even when no content changed. Two consecutive ``python scripts/_generate_notebooks.py`` invocations are now byte-identical. - Migrate generator's internal triple-single-quote strings to triple-double-quote so ``ruff format --check scripts/`` stays clean. Notebook content is unaffected (the generated cell source text is identical).
1 parent 298f8d2 commit 537ae84

10 files changed

Lines changed: 217 additions & 195 deletions

examples/00_colab_quickstart.ipynb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "6904d358",
5+
"id": "254b20b3a8fd",
66
"metadata": {},
77
"source": [
88
"# QQA 00 – Colab quickstart\n",
@@ -15,7 +15,7 @@
1515
{
1616
"cell_type": "code",
1717
"execution_count": null,
18-
"id": "acbc3c0b",
18+
"id": "6a4fe4199e10",
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
@@ -37,15 +37,15 @@
3737
},
3838
{
3939
"cell_type": "markdown",
40-
"id": "0b38d580",
40+
"id": "7347ef8775b1",
4141
"metadata": {},
4242
"source": [
4343
"This notebook walks through every problem family shipped with QQA on Google Colab. It installs `qqa` **from PyPI**, detects CUDA if available, and runs a small `qqa.anneal` job per problem with an inline `viz.plot_history` / `viz.plot_best_trajectory` figure. The whole notebook finishes in ~2 minutes on a free CPU Colab runtime and ~30s on a GPU runtime. Set `QQA_INSTALL_FROM_GIT=1` before the install cell to track the `main` branch instead."
4444
]
4545
},
4646
{
4747
"cell_type": "markdown",
48-
"id": "7c47115d",
48+
"id": "6a4108e36a7c",
4949
"metadata": {},
5050
"source": [
5151
"## Setup"
@@ -54,7 +54,7 @@
5454
{
5555
"cell_type": "code",
5656
"execution_count": null,
57-
"id": "6e69595b",
57+
"id": "0a4c2405e5c1",
5858
"metadata": {},
5959
"outputs": [],
6060
"source": [
@@ -73,7 +73,7 @@
7373
},
7474
{
7575
"cell_type": "markdown",
76-
"id": "60bf9ba5",
76+
"id": "a1d6b65223af",
7777
"metadata": {},
7878
"source": [
7979
"## 1. Maximum Independent Set"
@@ -82,7 +82,7 @@
8282
{
8383
"cell_type": "code",
8484
"execution_count": null,
85-
"id": "dce4ea02",
85+
"id": "166cc91b9c5c",
8686
"metadata": {},
8787
"outputs": [],
8888
"source": [
@@ -95,7 +95,7 @@
9595
},
9696
{
9797
"cell_type": "markdown",
98-
"id": "fb87c190",
98+
"id": "71a6c816406c",
9999
"metadata": {},
100100
"source": [
101101
"## 2. Graph coloring (K=3)"
@@ -104,7 +104,7 @@
104104
{
105105
"cell_type": "code",
106106
"execution_count": null,
107-
"id": "ff486cca",
107+
"id": "cc306eed64e7",
108108
"metadata": {},
109109
"outputs": [],
110110
"source": [
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"cell_type": "markdown",
120-
"id": "8e6222c0",
120+
"id": "bb0aaea6378f",
121121
"metadata": {},
122122
"source": [
123123
"## 3. Max-Cut"
@@ -126,7 +126,7 @@
126126
{
127127
"cell_type": "code",
128128
"execution_count": null,
129-
"id": "181471a7",
129+
"id": "2ff71834e1dc",
130130
"metadata": {},
131131
"outputs": [],
132132
"source": [
@@ -139,7 +139,7 @@
139139
},
140140
{
141141
"cell_type": "markdown",
142-
"id": "dda9a251",
142+
"id": "62e409402b24",
143143
"metadata": {},
144144
"source": [
145145
"## 4. 1D Ising ferromagnet"
@@ -148,7 +148,7 @@
148148
{
149149
"cell_type": "code",
150150
"execution_count": null,
151-
"id": "b2cf9ce0",
151+
"id": "707bc9b62ee6",
152152
"metadata": {},
153153
"outputs": [],
154154
"source": [
@@ -160,7 +160,7 @@
160160
},
161161
{
162162
"cell_type": "markdown",
163-
"id": "6adae43d",
163+
"id": "cb008d11d283",
164164
"metadata": {},
165165
"source": [
166166
"## 5. Edwards–Anderson 3D spin glass"
@@ -169,7 +169,7 @@
169169
{
170170
"cell_type": "code",
171171
"execution_count": null,
172-
"id": "87ad38ac",
172+
"id": "54542447a433",
173173
"metadata": {},
174174
"outputs": [],
175175
"source": [
@@ -181,7 +181,7 @@
181181
},
182182
{
183183
"cell_type": "markdown",
184-
"id": "23e94f06",
184+
"id": "161618c1dbdb",
185185
"metadata": {},
186186
"source": [
187187
"## 6. Sherrington–Kirkpatrick"
@@ -190,7 +190,7 @@
190190
{
191191
"cell_type": "code",
192192
"execution_count": null,
193-
"id": "8adfd1a9",
193+
"id": "2b8b0b0065f3",
194194
"metadata": {},
195195
"outputs": [],
196196
"source": [
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"cell_type": "markdown",
205-
"id": "8eb8b6c6",
205+
"id": "3c2f70df5e53",
206206
"metadata": {},
207207
"source": [
208208
"## 7. Binary perceptron"
@@ -211,7 +211,7 @@
211211
{
212212
"cell_type": "code",
213213
"execution_count": null,
214-
"id": "d3c904b6",
214+
"id": "e5b1096ad856",
215215
"metadata": {},
216216
"outputs": [],
217217
"source": [
@@ -224,7 +224,7 @@
224224
},
225225
{
226226
"cell_type": "markdown",
227-
"id": "8a4ba5c6",
227+
"id": "398b3702283e",
228228
"metadata": {},
229229
"source": [
230230
"## 8. Hopfield memory"
@@ -233,7 +233,7 @@
233233
{
234234
"cell_type": "code",
235235
"execution_count": null,
236-
"id": "f503e1a9",
236+
"id": "171b957c9c18",
237237
"metadata": {},
238238
"outputs": [],
239239
"source": [
@@ -247,7 +247,7 @@
247247
},
248248
{
249249
"cell_type": "markdown",
250-
"id": "bdca0090",
250+
"id": "af78ffc7c942",
251251
"metadata": {},
252252
"source": [
253253
"## 9. Parallel MIS (`MaximumIndependentSetInstance`)"
@@ -256,7 +256,7 @@
256256
{
257257
"cell_type": "code",
258258
"execution_count": null,
259-
"id": "87b93879",
259+
"id": "66c9ce81ac03",
260260
"metadata": {},
261261
"outputs": [],
262262
"source": [
@@ -270,7 +270,7 @@
270270
},
271271
{
272272
"cell_type": "markdown",
273-
"id": "d9ca8923",
273+
"id": "91f1cffb4dd9",
274274
"metadata": {},
275275
"source": [
276276
"## Custom loss via `UserProblem`"
@@ -279,7 +279,7 @@
279279
{
280280
"cell_type": "code",
281281
"execution_count": null,
282-
"id": "3a4589aa",
282+
"id": "232fa66b0632",
283283
"metadata": {},
284284
"outputs": [],
285285
"source": [

examples/01_maximum_independent_set.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "5d625f40",
5+
"id": "fb3e4eb308dc",
66
"metadata": {},
77
"source": [
88
"# QQA 01 – Maximum Independent Set\n",
@@ -15,7 +15,7 @@
1515
{
1616
"cell_type": "code",
1717
"execution_count": null,
18-
"id": "1a61fdc6",
18+
"id": "d68d5f74ac52",
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"cell_type": "markdown",
40-
"id": "7ced3895",
40+
"id": "fbcba2b43f5e",
4141
"metadata": {},
4242
"source": [
4343
"## Setup"
@@ -46,7 +46,7 @@
4646
{
4747
"cell_type": "code",
4848
"execution_count": null,
49-
"id": "ba4d6fe2",
49+
"id": "75c8b28503bd",
5050
"metadata": {},
5151
"outputs": [],
5252
"source": [
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "markdown",
65-
"id": "0dfa93fc",
65+
"id": "a90c61061968",
6666
"metadata": {},
6767
"source": [
6868
"## Problem: Maximum Independent Set on a random regular graph"
@@ -71,7 +71,7 @@
7171
{
7272
"cell_type": "code",
7373
"execution_count": null,
74-
"id": "3d39771a",
74+
"id": "016b7fc2caa8",
7575
"metadata": {},
7676
"outputs": [],
7777
"source": [
@@ -82,7 +82,7 @@
8282
},
8383
{
8484
"cell_type": "markdown",
85-
"id": "3d94384c",
85+
"id": "d1bb69ff178a",
8686
"metadata": {},
8787
"source": [
8888
"## Run QQA"
@@ -91,7 +91,7 @@
9191
{
9292
"cell_type": "code",
9393
"execution_count": null,
94-
"id": "950a2674",
94+
"id": "41f50d27adec",
9595
"metadata": {},
9696
"outputs": [],
9797
"source": [
@@ -102,7 +102,7 @@
102102
},
103103
{
104104
"cell_type": "markdown",
105-
"id": "57598103",
105+
"id": "ac4dc083a5ae",
106106
"metadata": {},
107107
"source": [
108108
"## Visualise the dynamics"
@@ -111,7 +111,7 @@
111111
{
112112
"cell_type": "code",
113113
"execution_count": null,
114-
"id": "75339e9f",
114+
"id": "26797cb8fa7e",
115115
"metadata": {},
116116
"outputs": [],
117117
"source": [

examples/02_graph_coloring.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "e7436ffd",
5+
"id": "4680c1b68636",
66
"metadata": {},
77
"source": [
88
"# QQA 02 – Graph coloring\n",
@@ -15,7 +15,7 @@
1515
{
1616
"cell_type": "code",
1717
"execution_count": null,
18-
"id": "874030cf",
18+
"id": "965fb1844c29",
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
@@ -38,7 +38,7 @@
3838
{
3939
"cell_type": "code",
4040
"execution_count": null,
41-
"id": "6f71339a",
41+
"id": "588aa37c0530",
4242
"metadata": {},
4343
"outputs": [],
4444
"source": [
@@ -55,7 +55,7 @@
5555
{
5656
"cell_type": "code",
5757
"execution_count": null,
58-
"id": "19c0e31f",
58+
"id": "91a20f5e27a4",
5959
"metadata": {},
6060
"outputs": [],
6161
"source": [
@@ -66,7 +66,7 @@
6666
{
6767
"cell_type": "code",
6868
"execution_count": null,
69-
"id": "0641e5d8",
69+
"id": "0f92d0e54bfe",
7070
"metadata": {},
7171
"outputs": [],
7272
"source": [
@@ -77,7 +77,7 @@
7777
{
7878
"cell_type": "code",
7979
"execution_count": null,
80-
"id": "ff7caa7f",
80+
"id": "a01ceb0d438e",
8181
"metadata": {},
8282
"outputs": [],
8383
"source": [

0 commit comments

Comments
 (0)