improve nb

This commit is contained in:
Pierre Guillod 2024-09-08 01:44:29 +02:00
parent b2b6b03e35
commit cc0f631952

View file

@ -16,7 +16,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"id": "e2abc871-bf82-4cf6-993e-cd904c7e7468", "id": "e2abc871-bf82-4cf6-993e-cd904c7e7468",
"metadata": { "metadata": {
"editable": true, "editable": true,
@ -43,7 +43,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 2,
"id": "529de80c-dd7f-45eb-b3c1-753b33d2bdb7", "id": "529de80c-dd7f-45eb-b3c1-753b33d2bdb7",
"metadata": { "metadata": {
"editable": true, "editable": true,
@ -56,7 +56,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "414db3070b5e4673a30c4da2f9e98369", "model_id": "c0176080a16b4a30a7e18ab24b942c09",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
@ -64,7 +64,7 @@
"HBox(children=(VBox(children=(Dropdown(description='Région', options=(('Ville de Genève', 'geneva'), ('Région …" "HBox(children=(VBox(children=(Dropdown(description='Région', options=(('Ville de Genève', 'geneva'), ('Région …"
] ]
}, },
"execution_count": 39, "execution_count": 2,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -241,7 +241,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 5,
"id": "f4440649-731e-421e-b43d-17576bb8ad3f", "id": "f4440649-731e-421e-b43d-17576bb8ad3f",
"metadata": { "metadata": {
"editable": true, "editable": true,
@ -254,21 +254,21 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "4de6b53f8da74947ad6e78a65dc0a13f", "model_id": "9f2e4d21173a48fa9b9d3f115fb84741",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
"text/plain": [ "text/plain": [
"HBox(children=(VBox(children=(HBox(children=(IntSlider(value=1, description='0 véhic.', max=10, min=1, readout…" "HBox(children=(VBox(children=(HBox(children=(IntSlider(value=1, description='4400 véhic.', max=10, min=1, read…"
] ]
}, },
"execution_count": 38, "execution_count": 5,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"slider = widgets.IntSlider(\n", "w_slider = widgets.IntSlider(\n",
" min=1,\n", " min=1,\n",
" max=10,\n", " max=10,\n",
" step=1,\n", " step=1,\n",
@ -281,24 +281,47 @@
"def compute(*ignore):\n", "def compute(*ignore):\n",
" \n", " \n",
" shoteach = np.ceil(places[w_place.value][\"cars\"] * mots[\"car\"][\"ppv\"] / mots[w_mot.value][\"ppv\"]) / 10;\n", " shoteach = np.ceil(places[w_place.value][\"cars\"] * mots[\"car\"][\"ppv\"] / mots[w_mot.value][\"ppv\"]) / 10;\n",
" slider.description = f\"{slider.value * shoteach:.0f} véhic.\"\n", " w_slider.description = f\"{w_slider.value * shoteach:.0f} véhic.\"\n",
" file = open(f\"./outputs/{places[w_place.value][\"shorthand\"]}/plot_{w_mot.value}_{slider.value}.svg\", \"rb\")\n", " file = open(f\"./outputs/{places[w_place.value][\"shorthand\"]}/plot_{w_mot.value}_{w_slider.value}.svg\", \"rb\")\n",
" read = file.read()\n", " read = file.read()\n",
" image.value = read\n", " image.value = read\n",
"\n", "\n",
"slider.observe(compute, 'value')\n", "w_slider.observe(compute, 'value')\n",
"w_mot.observe(compute, 'value')\n", "w_mot.observe(compute, 'value')\n",
"w_place.observe(compute, 'value')\n", "w_place.observe(compute, 'value')\n",
"\n", "\n",
"widgets.HBox([widgets.VBox([widgets.HBox([slider], layout=widgets.Layout(justify_content=\"center\")), image], layout=widgets.Layout(max_width=\"700px\"))], layout=widgets.Layout(justify_content=\"center\"))" "compute()\n",
"\n",
"widgets.HBox([widgets.VBox([widgets.HBox([w_slider], layout=widgets.Layout(justify_content=\"center\")), image], layout=widgets.Layout(max_width=\"700px\"))], layout=widgets.Layout(justify_content=\"center\"))"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"id": "adf24613-a4ab-433f-8a1d-6e1d168163aa", "id": "adf24613-a4ab-433f-8a1d-6e1d168163aa",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/html": [
"\n",
"<style>\n",
"h1, p {\n",
" display: block !important;\n",
" max-width: 700px !important;\n",
" margin: 0 auto !important;\n",
"}\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"from IPython.core.display import HTML\n", "from IPython.core.display import HTML\n",
"HTML(\"\"\"\n", "HTML(\"\"\"\n",
@ -311,6 +334,14 @@
"</style>\n", "</style>\n",
"\"\"\")" "\"\"\")"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9fce8609-077d-460d-8340-fa1b6b5167b7",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {