Skip to content
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

Empty AssertionError when using np.array #24

Closed
ArthurAttout opened this issue Dec 15, 2018 · 1 comment · Fixed by #26
Closed

Empty AssertionError when using np.array #24

ArthurAttout opened this issue Dec 15, 2018 · 1 comment · Fixed by #26
Assignees

Comments

@ArthurAttout
Copy link

When trying to create a network graph from Jupyter with np.array as input, an exception is thrown

arrayNodes = np.array([1,2,3,4])
g = Network(notebook=True)
g.add_nodes(np.array([1,2,3,4]))

throws


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-91-b8c17924b890> in <module>()
      1 arrayNodes = np.array([1,2,3,4])
      2 g = Network(notebook=True)
----> 3 g.add_nodes(np.array([1,2,3,4]))

C:\anaconda\lib\site-packages\pyvis\network.py in add_nodes(self, nodes, **kwargs)
    247 
    248         for node in nodes:
--> 249             assert isinstance(node, int) or isinstance(node, str)
    250             self.add_node(node, **nd[node])
    251 

AssertionError: 

@boludo00
Copy link
Collaborator

boludo00 commented Mar 6, 2019

When I first wrote that method I wanted to just enforce node values I knew the VisJS engine would not complain about, which explains the odd assertion. I think each value of the np array is something like a specifc numpy data type, that's why the assert fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants