Skip to content

Commit e22b3f4

Browse files
committed
Fixed matplotlib errors in shooting method notebook. Resolved issue with using nested boxes in voila for displaying widgets side-by-side by using AppLayout instead.
1 parent 10307ea commit e22b3f4

File tree

1 file changed

+73
-14
lines changed

1 file changed

+73
-14
lines changed

notebook/quantum-mechanics/shooting_method.ipynb

+73-14
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
},
107107
{
108108
"cell_type": "code",
109-
"execution_count": null,
109+
"execution_count": 5,
110110
"metadata": {},
111111
"outputs": [],
112112
"source": [
@@ -121,7 +121,7 @@
121121
},
122122
{
123123
"cell_type": "code",
124-
"execution_count": null,
124+
"execution_count": 6,
125125
"metadata": {},
126126
"outputs": [],
127127
"source": [
@@ -221,9 +221,38 @@
221221
},
222222
{
223223
"cell_type": "code",
224-
"execution_count": null,
224+
"execution_count": 7,
225225
"metadata": {},
226-
"outputs": [],
226+
"outputs": [
227+
{
228+
"data": {
229+
"application/vnd.jupyter.widget-view+json": {
230+
"model_id": "0c205274437f4883b6b9a654632ebc51",
231+
"version_major": 2,
232+
"version_minor": 0
233+
},
234+
"text/plain": [
235+
"HBox(children=(VBox(children=(Label(value='Targeted eigenvalue'), HBox(children=(FloatSlider(value=-0.03, layo…"
236+
]
237+
},
238+
"metadata": {},
239+
"output_type": "display_data"
240+
},
241+
{
242+
"data": {
243+
"application/vnd.jupyter.widget-view+json": {
244+
"model_id": "7befa6aa973542e698ef88e678524448",
245+
"version_major": 2,
246+
"version_minor": 0
247+
},
248+
"text/plain": [
249+
"Output()"
250+
]
251+
},
252+
"metadata": {},
253+
"output_type": "display_data"
254+
}
255+
],
227256
"source": [
228257
"mu = 0.06 # Potential parameter\n",
229258
"L = 1.5 # x range [-L,L]\n",
@@ -363,8 +392,8 @@
363392
"\n",
364393
"def on_width_change(change):\n",
365394
" global ew, ef, x, dx, V\n",
366-
" ax[0].lines.clear()\n",
367-
" ax[1].lines.clear()\n",
395+
" ax[0].clear()\n",
396+
" ax[1].clear()\n",
368397
" \n",
369398
" try:\n",
370399
" ann.remove()\n",
@@ -377,8 +406,8 @@
377406
"\n",
378407
"def on_depth_change(change):\n",
379408
" global ew, ef, x, dx, V\n",
380-
" ax[0].lines.clear()\n",
381-
" ax[1].lines.clear()\n",
409+
" ax[0].clear()\n",
410+
" ax[1].clear()\n",
382411
" \n",
383412
" try:\n",
384413
" ann.remove()\n",
@@ -391,8 +420,8 @@
391420
" loop1.max = max(V)\n",
392421
" \n",
393422
"def on_xfak_change(change):\n",
394-
" ax[0].lines.clear()\n",
395-
" ax[1].lines.clear()\n",
423+
" ax[0].clear()\n",
424+
" ax[1].clear()\n",
396425
" \n",
397426
" try:\n",
398427
" ann.remove()\n",
@@ -455,7 +484,8 @@
455484
"label3 = Label(value=\"(click on a state to select it)\")\n",
456485
"label4 = Label(value=\"(tune to zoom the eigenfunctions)\")\n",
457486
"\n",
458-
"display(HBox([VBox([label1, HBox([loop1, loop2, loop3, loop4]), Leng, search, order, label2, flip]), output]))"
487+
"full_layout=HBox([VBox([label1, HBox([loop1, loop2, loop3, loop4]), Leng, search, order, label2, flip]),output])\n",
488+
"display(full_layout)"
459489
]
460490
},
461491
{
@@ -467,9 +497,38 @@
467497
},
468498
{
469499
"cell_type": "code",
470-
"execution_count": null,
500+
"execution_count": 8,
471501
"metadata": {},
472-
"outputs": [],
502+
"outputs": [
503+
{
504+
"data": {
505+
"application/vnd.jupyter.widget-view+json": {
506+
"model_id": "d36195895f1c408c806c02869c447a75",
507+
"version_major": 2,
508+
"version_minor": 0
509+
},
510+
"text/plain": [
511+
"HBox(children=(FloatSlider(value=1.2, description='Width: ', max=2.0, min=0.1), FloatSlider(value=0.2, descrip…"
512+
]
513+
},
514+
"metadata": {},
515+
"output_type": "display_data"
516+
},
517+
{
518+
"data": {
519+
"application/vnd.jupyter.widget-view+json": {
520+
"model_id": "028876bb1fec458ab2cf5bc547bd4011",
521+
"version_major": 2,
522+
"version_minor": 0
523+
},
524+
"text/plain": [
525+
"VBox(children=(HBox(children=(FloatSlider(value=3.0, description='Zoom factor: ', max=5.0, min=1.0, step=0.5),…"
526+
]
527+
},
528+
"metadata": {},
529+
"output_type": "display_data"
530+
}
531+
],
473532
"source": [
474533
"display(HBox([swidth, sdepth]), VBox([HBox([sfak, label4]), HBox([update, label3])]))"
475534
]
@@ -535,7 +594,7 @@
535594
"name": "python",
536595
"nbconvert_exporter": "python",
537596
"pygments_lexer": "ipython3",
538-
"version": "3.11.0"
597+
"version": "3.10.12"
539598
},
540599
"voila": {
541600
"authors": "Dou Du and Giovanni Pizzi"

0 commit comments

Comments
 (0)