Skip to content

Commit

Permalink
Start with visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
YouGuessedMyName committed Jun 26, 2024
1 parent f79e620 commit a000256
Show file tree
Hide file tree
Showing 6 changed files with 1,286 additions and 14 deletions.
90 changes: 80 additions & 10 deletions notebooks/die.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,111 @@
"metadata": {},
"outputs": [],
"source": [
"from stormvogel.visualization import make_slider"
"import stormvogel.model\n",
"import stormvogel.visualization"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Create a new model with the name \"Die\"\n",
"dtmc = stormvogel.model.new_dtmc(\"Die\")\n",
"\n",
"init = dtmc.get_initial_state()\n",
"\n",
"# From the initial state, add the transition to 6 new states with probability 1/6th.\n",
"init.set_transitions(\n",
" [(1 / 6, dtmc.new_state(f\"rolled{i}\", {\"rolled\": i})) for i in range(6)]\n",
")\n",
"\n",
"# Print the resulting model in dot format.\n",
"# print(dtmc.to_dot())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"diegraph.html\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9caed9de44144d50b26a7e76ef0accb8",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"diegraph.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…"
"<IPython.lib.display.IFrame at 0x7ff90d17b510>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"stormvogel.visualization.show(model=dtmc, name=\"diegraph\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"hi.html\n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"hi.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<function stormvogel.visualization.make_slider.<locals>.<lambda>(x)>"
"<IPython.lib.display.IFrame at 0x7ff90ec3a110>"
]
},
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"make_slider()"
"from pyvis.network import Network\n",
"\n",
"g = Network(notebook=True,cdn_resources=\"remote\")\n",
"g.show_buttons()\n",
"g.show(\"hi.html\")"
]
},
{
Expand Down
Loading

0 comments on commit a000256

Please sign in to comment.