Skip to content

Commit

Permalink
reverted new exploration code
Browse files Browse the repository at this point in the history
  • Loading branch information
YouGuessedMyName committed Feb 2, 2025
1 parent 41b7136 commit 09ca5a8
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 269 deletions.
161 changes: 6 additions & 155 deletions docs/getting_started/01_study.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 14,
"id": "0df1511e-565d-45d0-93a8-adafbfaaaefa",
"metadata": {
"scrolled": true
Expand All @@ -164,7 +164,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "be7c1a38bc504a67abc215743d681813",
"model_id": "bd157ce6c3034fd5a0533f8220e44c9e",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -175,44 +175,10 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script>\n",
"function return_id_result(url, id, data) {\n",
" fetch(url, {\n",
" method: 'POST',\n",
" body: JSON.stringify({\n",
" 'id': id,\n",
" 'data': data\n",
" })\n",
" })\n",
" }\n",
"</script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"return_id_result('http://127.0.0.1:8889', 'zZtxQrYJanXwlIbrckDc', 'test message')"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f073135af213448c994b303e53484519",
"model_id": "f7080afa9cce47deb47ef9c1b145ce71",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -226,7 +192,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bd4476310d4241688ea7f374c549b0b5",
"model_id": "69b3da5b0e884431b9cb84d758067af4",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -236,131 +202,16 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"//js\n",
"document.getElementById('studywjFNvmgEOX').contentWindow.network.on( 'click', function(properties) {\n",
" var nodeId = document.getElementById('studywjFNvmgEOX').contentWindow.network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" if (! (nodeId === undefined)) {\n",
" return_id_result('http://127.0.0.1:8889', 'MoudfJVIPcWgNAgFZTZW', nodeId);\n",
" }\n",
"});"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"explore 10000000001\n",
"2\n",
"make visible 2 <class 'int'>\n",
"document.getElementById('studywjFNvmgEOX').contentWindow.nodes.update({ id: 2, label: `didn't study\n",
"\u20ac\tR: 15`, group: \"states\", x: 57, y: -10 });\n"
]
}
],
"source": [
"vis = show(mdp, layout=Layout(\"layouts/pinkgreen.json\"), name=\"study\", show_editor=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "6cb412a1-52fa-4663-b7ba-371e06001f7a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{0: {Edge(from_=0, to_=10000000000, label=None), Edge(from_=0, to_=10000000001, label=None)}, 10000000000: {Edge(from_=10000000000, to_=1, label='1')}, 10000000001: {Edge(from_=10000000001, to_=2, label='1')}, 1: {Edge(from_=1, to_=3, label='9/10'), Edge(from_=1, to_=4, label='1/10')}, 2: {Edge(from_=2, to_=4, label='3/5'), Edge(from_=2, to_=3, label='2/5')}, 3: {Edge(from_=3, to_=5, label='1')}, 4: {Edge(from_=4, to_=5, label='1')}}\n"
]
}
],
"source": [
"print(vis.nt.edges)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "f281c503-d45e-4f36-a368-71bda9e0a898",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"make visible 10000000001 <class 'int'>\n",
"document.getElementById('studywjFNvmgEOX').contentWindow.nodes.update({ id: 10000000001, label: `don't study\n",
"\u20ac\tR: 0`, group: \"actions\", x: 77, y: -144 });\n"
]
},
{
"data": {
"application/javascript": [
"document.getElementById('studywjFNvmgEOX').contentWindow.nodes.update({ id: 10000000001, label: `don't study\n",
"\u20ac\tR: 0`, group: \"actions\", x: 77, y: -144 });"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vis.nt.make_node_visible(10000000001, True)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "fee61f37-2e8e-48d0-9d57-e7f92c3effab",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"make visible 2 <class 'int'>\n",
"document.getElementById('studywjFNvmgEOX').contentWindow.nodes.update({ id: 2, label: `didn't study\n",
"\u20ac\tR: 15`, group: \"states\", x: 57, y: -10 });\n"
]
},
{
"data": {
"application/javascript": [
"document.getElementById('studywjFNvmgEOX').contentWindow.nodes.update({ id: 2, label: `didn't study\n",
"\u20ac\tR: 15`, group: \"states\", x: 57, y: -10 });"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vis.nt.make_node_visible(2, True)"
"vis = show(mdp, layout=Layout(\"layouts/pinkgreen.json\"), name=\"study\", show_editor=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ffb652e-e2ca-4212-b8b3-44db33ba46f3",
"id": "a9e68b97-49d8-47dc-8ba1-5d179bcecc52",
"metadata": {},
"outputs": [],
"source": []
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/layouts/pinkgreen.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"enable_physics": true,
"width": 800,
"height": 600,
"explore": true
"explore": false
},
"saving": {
"relative_path": true,
Expand Down
29 changes: 28 additions & 1 deletion docs/getting_started/study.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<iframe
id="studymrkLMSGkNb"
id="studyNsXSOjuhzk"
width="820"
height="620"
frameborder="0"
Expand Down Expand Up @@ -217,6 +217,33 @@
edges: edges,
};
var network = new vis.Network(container, data, options);
function makeAllNodesInvisible() {
ids = nodes.getIds();
for (let i = 0; i &lt; ids.length; i++) {
var nodeId = ids[i];
var node = nodes.get(nodeId);
node[&quot;hidden&quot;] = true;
nodes.update(node);
}
};
function makeNeighborsVisible(myNode) {
var ids = network.getConnectedNodes(myNode, &#x27;to&#x27;);
for (let i = 0; i &lt; ids.length; i++) {
var nodeId = ids[i];
var node = nodes.get(nodeId);
node[&quot;hidden&quot;] = false;
nodes.update(node);
}
};
function makeNodeVisible(nodeId) {
var node = nodes.get(nodeId);
node[&quot;hidden&quot;] = false;
nodes.update(node);
};
network.on( &#x27;click&#x27;, function(properties) {
var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});
makeNeighborsVisible(nodeId);
});
&lt;/script&gt;
&lt;/body&gt;
Expand Down
17 changes: 4 additions & 13 deletions stormvogel/html_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@
edges: edges,
};
var network = new vis.Network(container, data, options);
// network.on( 'click', function(properties) {
// var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});
// alert(nodeId);
// });
"""

NETWORK_JS_OLD = """//js
var container = document.getElementById("mynetwork");
var data = {
nodes: nodes,
edges: edges,
};
var network = new vis.Network(container, data, options);
function makeAllNodesInvisible() {
ids = nodes.getIds();
for (let i = 0; i < ids.length; i++) {
Expand All @@ -69,4 +56,8 @@
node["hidden"] = false;
nodes.update(node);
};
network.on( 'click', function(properties) {
var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});
makeNeighborsVisible(nodeId);
});
"""
1 change: 0 additions & 1 deletion stormvogel/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def show(
e.show()
box = widgets.HBox(children=[vis.output, e.output])
ipd.display(box)
vis.after_show()
else: # Unfortunately, the sphinx docs only work if we save the html as a file and embed.
iframe = vis.nt.generate_iframe()
with open(name + ".html", "w") as f:
Expand Down
Loading

0 comments on commit 09ca5a8

Please sign in to comment.