-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isinstance check too strict #16
Comments
Hi @bjodah , This is my output (Python3.6) from pyvis.network import Network |
Sure, I'm using pyvis 0.1.4.1 (what pip tells me, saw no import sys
import networkx as nx
from networkx.drawing.nx_agraph import graphviz_layout
import numpy as np
import pyvis
from pyvis import network as net
print('\n'.join(['%s: %s' % (m.__name__, m.__version__) for m in (nx, np)]))
print('python: {}'.format(sys.version_info))
def mk_graph(from_to):
dg = nx.DiGraph()
dg.add_nodes_from([0, 1, 2])
for src, dst_lst in from_to.items():
for dst in dst_lst:
dg.add_edge(src, dst)
return dg
def viz(gr):
pos = graphviz_layout(gr)
g = net.Network(notebook=True)
g.from_nx(gr)
for i, node in enumerate(g.nodes):
node['x'] = pos[i][0]
node['y'] = pos[i][1]
node['physics'] = False
for edge in g.edges:
edge['physics'] = False
return g
dg = mk_graph({0: np.array([1, 2], dtype=int)})
viz(dg) which gives me the following output in jupyter notebook:
|
I can fix the code by simply doing:
instead, so no biggie. |
So strange, that code didnt throw an error for me |
Hi, import networkx as nx
import scipy.sparse as sp
from pyvis.network import Network
M = sp.random(5,5,density=0.6)
G = nx.from_scipy_sparse_matrix(M)
nt = Network('500px', '500px')
nt.from_nx(G)
nt.show("nx.html") which throws the same error as above:
|
Hi, great project. |
Same here, trying to build a network graph from a scipy sparse matrix, converting to networkx and then pyvis. |
Any answer to the above fault ? from pyvis.network import Network nodes =[{"color": "red", "id": "2", "label": "N2", "shape": "o", "size": 50}, edges=[{"arrows": "to", "font_size": 8, "from": "1", "label": "L12 : 500", "to": "2", "weight": 500}, G = Network(width="800px", height='600px', heading='Test connectivity', layout=True, bgcolor='#aaaaaa', directed=True) Error: During handling of the above exception, another exception occurred: Traceback (most recent call last): Process finished with exit code 1 why is the code trying to check whether the data "node" is a string... As per documentation, the request "add_nodes" should parse a LIST data structure. |
Having the same error and could not find a fix yet. |
I resolved my similar error by dropping the indexes from my DataFrame with null values in the src and dst columns. |
After some investigation on the source code pyvis.readthedocs.io/en/latest/_modules/pyvis/network.html I found that the issue is that the only accepted format to add a node is either string and integer (check the
A way to solve this issue is converting all nodes to string before transferring from |
It is a bad design to force network nodes to be only int or str. Networkx takes any object and pyvis is based on that and it doesn't. Seems artificial bottleneck. |
Hi, thank you for making this project available--it looks really interesting.
I'm just getting started and immediately ran into this (when using
from_nx
):one possible fix would be to check against the abstract base class:
The text was updated successfully, but these errors were encountered: