Skip to content

Commit

Permalink
fixed viz by adding strict eq
Browse files Browse the repository at this point in the history
  • Loading branch information
YouGuessedMyName committed Nov 23, 2024
1 parent f4e0253 commit 907091a
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 98 deletions.
10 changes: 7 additions & 3 deletions docs/getting_started/study.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<iframe
id="studyUfXfviwmyR"
id="studyRIEgvYkaQK"
width="820"
height="620"
frameborder="0"
Expand Down Expand Up @@ -33,9 +33,13 @@
{ id: 3, label: `pass test`, group: &quot;states&quot;, x: 0, y: 99 },
{ id: 4, label: `fail test`, group: &quot;states&quot;, x: -24, y: 37 },
{ id: 5, label: `end`, group: &quot;states&quot;, x: -62, y: 182 },
{ id: 10000000000, label: `study`, group: &quot;actions&quot;, x: 119, y: -118 },
{ id: 10000000001, label: `don&#x27;t study`, group: &quot;actions&quot;, x: -122, y: -141 },
]);
var edges = new vis.DataSet([{ from: 0, to: 1, label: &quot;1&quot; },
{ from: 0, to: 2, label: &quot;1&quot; },
var edges = new vis.DataSet([{ from: 0, to: 10000000000 },
{ from: 10000000000, to: 1, label: &quot;1&quot; },
{ from: 0, to: 10000000001 },
{ from: 10000000001, to: 2, label: &quot;1&quot; },
{ from: 1, to: 3, label: &quot;9/10&quot; },
{ from: 1, to: 4, label: &quot;1/10&quot; },
{ from: 2, to: 3, label: &quot;2/5&quot; },
Expand Down
341 changes: 247 additions & 94 deletions docs/getting_started/study.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,114 +159,267 @@
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "49c25502d28d4fe886199ed1bee61a51",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script>fetch('http://127.0.0.1:8890/ohnWQsdOLs/MESSAGE/' + 'test message')</script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script>fetch('http://127.0.0.1:8890/ohnWQsdOLs/MESSAGE/' + 'test message')</script>"
"\n",
" <iframe\n",
" id=\"studyRIEgvYkaQK\"\n",
" width=\"820\"\n",
" height=\"620\"\n",
" frameborder=\"0\"\n",
" srcdoc=\"\n",
"&lt;!DOCTYPE html&gt;\n",
"&lt;html lang=&quot;en&quot;&gt;\n",
" &lt;head&gt;\n",
" &lt;title&gt;Network&lt;/title&gt;\n",
" &lt;script\n",
" type=&quot;text/javascript&quot;\n",
" src=&quot;https://unpkg.com/vis-network/standalone/umd/vis-network.min.js&quot;\n",
" &gt;&lt;/script&gt;\n",
" &lt;style type=&quot;text/css&quot;&gt;\n",
" #mynetwork {\n",
" \n",
" width: 800px;\n",
" height: 600px;\n",
" border: 1px solid lightgray;\n",
" \n",
" }\n",
" &lt;/style&gt;\n",
" &lt;/head&gt;\n",
" &lt;body&gt;\n",
" &lt;div id=&quot;mynetwork&quot;&gt;&lt;/div&gt;\n",
" &lt;script type=&quot;text/javascript&quot;&gt;\n",
" \n",
" var nodes = new vis.DataSet([{ id: 0, label: `init`, group: &quot;states&quot;, x: 5, y: -186 },\n",
"{ id: 1, label: `studied`, group: &quot;states&quot;, x: 98, y: 11 },\n",
"{ id: 2, label: `didn&#x27;t study`, group: &quot;states&quot;, x: -120, y: -7 },\n",
"{ id: 3, label: `pass test`, group: &quot;states&quot;, x: 0, y: 99 },\n",
"{ id: 4, label: `fail test`, group: &quot;states&quot;, x: -24, y: 37 },\n",
"{ id: 5, label: `end`, group: &quot;states&quot;, x: -62, y: 182 },\n",
"{ id: 10000000000, label: `study`, group: &quot;actions&quot;, x: 119, y: -118 },\n",
"{ id: 10000000001, label: `don&#x27;t study`, group: &quot;actions&quot;, x: -122, y: -141 },\n",
"]);\n",
" var edges = new vis.DataSet([{ from: 0, to: 10000000000 },\n",
"{ from: 10000000000, to: 1, label: &quot;1&quot; },\n",
"{ from: 0, to: 10000000001 },\n",
"{ from: 10000000001, to: 2, label: &quot;1&quot; },\n",
"{ from: 1, to: 3, label: &quot;9/10&quot; },\n",
"{ from: 1, to: 4, label: &quot;1/10&quot; },\n",
"{ from: 2, to: 3, label: &quot;2/5&quot; },\n",
"{ from: 2, to: 4, label: &quot;3/5&quot; },\n",
"{ from: 3, to: 5, label: &quot;1&quot; },\n",
"{ from: 4, to: 5, label: &quot;1&quot; },\n",
"]);\n",
" var options = {\n",
" &quot;__fake_macros&quot;: {\n",
" &quot;__group_macro&quot;: {\n",
" &quot;borderWidth&quot;: 1,\n",
" &quot;color&quot;: {\n",
" &quot;background&quot;: &quot;white&quot;,\n",
" &quot;border&quot;: &quot;black&quot;,\n",
" &quot;highlight&quot;: {\n",
" &quot;background&quot;: &quot;white&quot;,\n",
" &quot;border&quot;: &quot;red&quot;\n",
" }\n",
" },\n",
" &quot;shape&quot;: &quot;ellipse&quot;,\n",
" &quot;mass&quot;: 1,\n",
" &quot;font&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;,\n",
" &quot;size&quot;: 14\n",
" }\n",
" }\n",
" },\n",
" &quot;groups&quot;: {\n",
" &quot;states&quot;: {\n",
" &quot;borderWidth&quot;: 1,\n",
" &quot;color&quot;: {\n",
" &quot;background&quot;: &quot;#8ff0a4&quot;,\n",
" &quot;border&quot;: &quot;black&quot;,\n",
" &quot;highlight&quot;: {\n",
" &quot;background&quot;: &quot;white&quot;,\n",
" &quot;border&quot;: &quot;red&quot;\n",
" }\n",
" },\n",
" &quot;shape&quot;: &quot;ellipse&quot;,\n",
" &quot;mass&quot;: 1,\n",
" &quot;font&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;,\n",
" &quot;size&quot;: 14\n",
" }\n",
" },\n",
" &quot;actions&quot;: {\n",
" &quot;borderWidth&quot;: 1,\n",
" &quot;color&quot;: {\n",
" &quot;background&quot;: &quot;#ffc0cb&quot;,\n",
" &quot;border&quot;: &quot;black&quot;,\n",
" &quot;highlight&quot;: {\n",
" &quot;background&quot;: &quot;white&quot;,\n",
" &quot;border&quot;: &quot;red&quot;\n",
" }\n",
" },\n",
" &quot;shape&quot;: &quot;box&quot;,\n",
" &quot;mass&quot;: 1,\n",
" &quot;font&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;,\n",
" &quot;size&quot;: 14\n",
" }\n",
" },\n",
" &quot;scheduled_actions&quot;: {\n",
" &quot;borderWidth&quot;: 1,\n",
" &quot;color&quot;: {\n",
" &quot;background&quot;: &quot;pink&quot;,\n",
" &quot;border&quot;: &quot;black&quot;,\n",
" &quot;highlight&quot;: {\n",
" &quot;background&quot;: &quot;white&quot;,\n",
" &quot;border&quot;: &quot;red&quot;\n",
" }\n",
" },\n",
" &quot;shape&quot;: &quot;box&quot;,\n",
" &quot;mass&quot;: 1,\n",
" &quot;font&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;,\n",
" &quot;size&quot;: 14\n",
" },\n",
" &quot;schedColor&quot;: false\n",
" }\n",
" },\n",
" &quot;reload_button&quot;: false,\n",
" &quot;edges&quot;: {\n",
" &quot;arrows&quot;: &quot;to&quot;,\n",
" &quot;font&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;,\n",
" &quot;size&quot;: 14\n",
" },\n",
" &quot;color&quot;: {\n",
" &quot;color&quot;: &quot;black&quot;\n",
" }\n",
" },\n",
" &quot;numbers&quot;: {\n",
" &quot;fractions&quot;: true,\n",
" &quot;digits&quot;: 5\n",
" },\n",
" &quot;state_properties&quot;: {\n",
" &quot;show_results&quot;: true,\n",
" &quot;result_symbol&quot;: &quot;\\u2606&quot;,\n",
" &quot;show_rewards&quot;: true,\n",
" &quot;reward_symbol&quot;: &quot;\\u20ac&quot;,\n",
" &quot;show_observations&quot;: true,\n",
" &quot;observation_symbol&quot;: &quot;\\u0298&quot;\n",
" },\n",
" &quot;layout&quot;: {\n",
" &quot;randomSeed&quot;: 5\n",
" },\n",
" &quot;misc&quot;: {\n",
" &quot;enable_physics&quot;: true,\n",
" &quot;width&quot;: 800,\n",
" &quot;height&quot;: 600,\n",
" &quot;explore&quot;: false\n",
" },\n",
" &quot;saving&quot;: {\n",
" &quot;relative_path&quot;: true,\n",
" &quot;filename&quot;: &quot;pinkgreen.json&quot;,\n",
" &quot;save_button&quot;: false,\n",
" &quot;load_button&quot;: false\n",
" },\n",
" &quot;positions&quot;: {\n",
" &quot;0&quot;: {\n",
" &quot;x&quot;: 5,\n",
" &quot;y&quot;: -186\n",
" },\n",
" &quot;1&quot;: {\n",
" &quot;x&quot;: 98,\n",
" &quot;y&quot;: 11\n",
" },\n",
" &quot;2&quot;: {\n",
" &quot;x&quot;: -120,\n",
" &quot;y&quot;: -7\n",
" },\n",
" &quot;3&quot;: {\n",
" &quot;x&quot;: 0,\n",
" &quot;y&quot;: 99\n",
" },\n",
" &quot;4&quot;: {\n",
" &quot;x&quot;: -24,\n",
" &quot;y&quot;: 37\n",
" },\n",
" &quot;5&quot;: {\n",
" &quot;x&quot;: -62,\n",
" &quot;y&quot;: 182\n",
" },\n",
" &quot;10000000000&quot;: {\n",
" &quot;x&quot;: 119,\n",
" &quot;y&quot;: -118\n",
" },\n",
" &quot;10000000001&quot;: {\n",
" &quot;x&quot;: -122,\n",
" &quot;y&quot;: -141\n",
" }\n",
" },\n",
" &quot;width&quot;: 800,\n",
" &quot;height&quot;: 600,\n",
" &quot;physics&quot;: true,\n",
" &quot;results_and_rewards&quot;: {\n",
" &quot;show_results&quot;: true,\n",
" &quot;resultSymbol&quot;: &quot;\\u2606&quot;,\n",
" &quot;show_rewards&quot;: true\n",
" }\n",
"};\n",
" //js\n",
"var container = document.getElementById(&quot;mynetwork&quot;);\n",
"var data = {\n",
" nodes: nodes,\n",
" edges: edges,\n",
"};\n",
"var network = new vis.Network(container, data, options);\n",
"function makeAllNodesInvisible() {\n",
" ids = nodes.getIds();\n",
" for (let i = 0; i &lt; ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" var node = nodes.get(nodeId);\n",
" node[&quot;hidden&quot;] = true;\n",
" nodes.update(node);\n",
" }\n",
"};\n",
"function makeNeighborsVisible(myNode) {\n",
" var ids = network.getConnectedNodes(myNode, &#x27;to&#x27;);\n",
" for (let i = 0; i &lt; ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" var node = nodes.get(nodeId);\n",
" node[&quot;hidden&quot;] = false;\n",
" nodes.update(node);\n",
" }\n",
"};\n",
"function makeNodeVisible(nodeId) {\n",
" var node = nodes.get(nodeId);\n",
" node[&quot;hidden&quot;] = false;\n",
" nodes.update(node);\n",
"};\n",
"network.on( &#x27;click&#x27;, function(properties) {\n",
" var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" makeNeighborsVisible(nodeId);\n",
"});\n",
"\n",
" &lt;/script&gt;\n",
" &lt;/body&gt;\n",
"&lt;/html&gt;\n",
"\"\n",
" border:none !important;\n",
" allowfullscreen webkitallowfullscreen mozallowfullscreen\n",
" ></iframe>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9ce2d3da2f694451ae010d110738b83b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Action study with labels frozenset() adding node\n",
"Action don't study with labels frozenset() adding node\n",
"Action empty with labels frozenset() was empty\n",
"Action empty with labels frozenset() was empty\n",
"Action empty with labels frozenset() was empty\n",
"Action empty with labels frozenset() was empty\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "372aa910075a49a09d0a6601a3714e72",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), Output()))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vis = show(mdp, layout=Layout(\"layouts/pinkgreen.json\"), name=\"study\", show_editor=True)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "393f4c6e-8204-42fc-8e0d-b2b8f232294a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Action study with labels frozenset()\n"
]
}
],
"source": [
"print(study)"
"vis = show(mdp, layout=Layout(\"layouts/pinkgreen.json\"), name=\"study\", save_and_embed=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea64a261-460e-4e7a-86a9-ad10e310d065",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
6 changes: 6 additions & 0 deletions stormvogel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def __eq__(self, other):
if isinstance(other, Action):
return self.labels == other.labels
return False

def strict_eq(self, other):
"""Also requires the names to be equal."""
if isinstance(other, Action):
return self.name == other.name and self.labels == other.labels
return False


# The empty action. Used for DTMCs and empty action transitions in mdps.
Expand Down
Loading

0 comments on commit 907091a

Please sign in to comment.