From 5fbe88d120d328766d2ac1e48b37cefaf8eeb8ce Mon Sep 17 00:00:00 2001 From: mpscherer Date: Mon, 6 Feb 2023 14:40:31 -0800 Subject: [PATCH] reverted change to write html name generation. --- notebooks/example.ipynb | 177 +++++++++++++++++++++++++++++++++++++--- pyvis/network.py | 2 +- 2 files changed, 165 insertions(+), 14 deletions(-) diff --git a/notebooks/example.ipynb b/notebooks/example.ipynb index a414766..e6ce4b8 100644 --- a/notebooks/example.ipynb +++ b/notebooks/example.ipynb @@ -38,7 +38,7 @@ " " + "" ] }, "execution_count": 2, @@ -81,14 +81,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n", + "dot.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "h = Network(notebook=True)\n", "h.from_DOT(\"test.dot\")\n", @@ -138,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "pycharm": { "name": "#%%\n" @@ -151,14 +182,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "example2.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "nxg = nx.random_tree(20)\n", "g.from_nx(nxg)\n", @@ -178,13 +239,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "example3.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "g.toggle_physics(False)\n", "g.show(\"example3.html\")" @@ -203,13 +294,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "example4.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "g = Network(notebook=True,cdn_resources='remote')\n", "g.add_nodes([1,2,3],\n", @@ -242,14 +363,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "example5.html\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import pandas as pd\n", "\n", diff --git a/pyvis/network.py b/pyvis/network.py index 0fa63ec..d7136f3 100644 --- a/pyvis/network.py +++ b/pyvis/network.py @@ -510,7 +510,7 @@ def write_html(self, name, local=True, notebook=False,open_browser=False): @param notebook: If true, this object will return the iframe document for use in juptyer notebook. @param open_browser: If true, will open a web browser with the generated graph. """ - getcwd_name = os.getcwd() + "/" + name + getcwd_name = name check_html(getcwd_name) self.html = self.generate_html(notebook=notebook)