diff --git a/docs/practical_examples/knowledge_graph.ipynb b/docs/practical_examples/knowledge_graph.ipynb index 06c4cbd..bea4f90 100644 --- a/docs/practical_examples/knowledge_graph.ipynb +++ b/docs/practical_examples/knowledge_graph.ipynb @@ -216,63 +216,32 @@ ] }, { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" + "ename": "UnicodeEncodeError", + "evalue": "'charmap' codec can't encode characters in position 263607-263621: character maps to ", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mUnicodeEncodeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[10], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m pyvis_graph\u001b[38;5;241m=\u001b[39m subgraph\u001b[38;5;241m.\u001b[39mbuild_pyvis_graph(notebook\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, style\u001b[38;5;241m=\u001b[39mVIS_STYLE)\n\u001b[0;32m 2\u001b[0m pyvis_graph\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[43mpyvis_graph\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mgraph.html\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnotebook\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\site-packages\\pyvis\\network.py:546\u001b[0m, in \u001b[0;36mNetwork.show\u001b[1;34m(self, name, local, notebook)\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[38;5;28mprint\u001b[39m(name)\n\u001b[0;32m 545\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m notebook:\n\u001b[1;32m--> 546\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite_html\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopen_browser\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43mnotebook\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[0;32m 547\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 548\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mwrite_html(name, open_browser\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", + "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\site-packages\\pyvis\\network.py:530\u001b[0m, in \u001b[0;36mNetwork.write_html\u001b[1;34m(self, name, local, notebook, open_browser)\u001b[0m\n\u001b[0;32m 528\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcdn_resources \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mremote\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 529\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(getcwd_name, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw+\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m out:\n\u001b[1;32m--> 530\u001b[0m \u001b[43mout\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhtml\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 531\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 532\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcdn_resources is not in [\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124min_line\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mremote\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocal\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m].\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[1;32m~\\anaconda3\\envs\\h5tbx\\lib\\encodings\\cp1252.py:19\u001b[0m, in \u001b[0;36mIncrementalEncoder.encode\u001b[1;34m(self, input, final)\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mencode\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m, final\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m---> 19\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcodecs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcharmap_encode\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43merrors\u001b[49m\u001b[43m,\u001b[49m\u001b[43mencoding_table\u001b[49m\u001b[43m)\u001b[49m[\u001b[38;5;241m0\u001b[39m]\n", + "\u001b[1;31mUnicodeEncodeError\u001b[0m: 'charmap' codec can't encode characters in position 263607-263621: character maps to " + ] } ], "source": [ "pyvis_graph= subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)\n", - "pyvis_graph.show('graph.html')" + "pyvis_graph.cdn_resources = 'in_line'\n", + "pyvis_graph.show('graph.html', notebook=True)" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "a44f0039-00b8-44c5-b237-ccba12993bdd", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"@context\": {\n", - " \"fname\": \"http://xmlns.com/foaf/0.1/firstName\",\n", - " \"lname\": \"http://xmlns.com/foaf/0.1/lastName\"\n", - " },\n", - " \"@graph\": [\n", - " {\n", - " \"@id\": \"http://www.w3.org/ns/prov#Person\",\n", - " \"fname\": \"Matthias\",\n", - " \"lname\": \"Probst\"\n", - " },\n", - " {\n", - " \"@id\": \"_:N14\",\n", - " \"http://www.w3.org/2004/02/skos/core#definition\": \"A hint\"\n", - " }\n", - " ]\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "with h5tbx.File() as h5:\n", " h5.create_dataset(name='test', data=4.3)\n", @@ -290,7 +259,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "3e8834fc-6217-42c3-b442-2565b012f828", "metadata": {}, "outputs": [], @@ -302,7 +271,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "077911e8-8bc3-4b58-a480-df605bdceae4", "metadata": {}, "outputs": [], @@ -317,41 +286,10 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "id": "67f99459-8351-4819-8a67-2b58d4b1e398", "metadata": {}, - "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", - "tmp.grpah.html\n" - ] - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "kg_from_jsonld = kglab.KnowledgeGraph().load_jsonld('test.jsonld')\n", "\n",