Open joseberlines opened 3 years ago
Do you have a complete example you can post? I would expect that after creation then display(G)
should always display something. If it doesn't you may well have found a bug. To check that I would open the browser javascript console and see if there are any errors there. (See https://webmasters.stackexchange.com/a/77337/115742 for how to open the javascript console)
Ok. Next time I post the whole example. I will close this one. I am opening too many issues
@ianhi I got an example of the above mentioned issue.
I am manipulating nodes with pandas and I could not display a graph:
then I realised that I made a mistake if I print the nodes with G.graph.nodes()
[Node(data={'id': 'BER', 'label': 'BER Hbf', 'classes': 'east'}, position={'x': nan, 'y': nan}), Node(data={'id': 'MUN', 'label': 'MUN Hbf', 'classes': 'west'}, position={'x': nan, 'y': nan}), Node(data={'id': 'FRA', 'label': 'HBf FRA', 'classes': 'west'}, position={'x': nan, 'y': nan}), Node(data={'id': 'HAM', 'label': 'HBf HAM', 'classes': 'west'}, position={'x': nan, 'y': nan}), Node(data={'id': 'LEP', 'label': 'HBf LEP', 'classes': 'east'}, position={'x': nan, 'y': nan}), Node(data={'id': 'NUR', 'label': 'HBf NUR', 'classes': 'west'}, position={'x': nan, 'y': nan}), Node(data={'id': 'PAR', 'label': 'PAR CS', 'classes': 'EU'}, position={'x': nan, 'y': nan}), Node(data={'id': 'MIL', 'label': 'MIL CS', 'classes': 'EU'}, position={'x': nan, 'y': nan}), Node(data={'id': 'BAR', 'label': 'BAR CS', 'classes': 'EU'}, position={'x': nan, 'y': nan}), Node(data={'id': 'LYO', 'label': 'LYO CS', 'classes': 'EU'}, position={'x': nan, 'y': nan}), Node(data={'id': 'LON', 'label': 'LON CS', 'classes': 'EU'}, position={'x': nan, 'y': nan}), Node(data={'id': 'LIS', 'label': 'LIS CS', 'classes': 'EU'}, position={'x': 0.0, 'y': 0.0}), Node(data={'id': 'WAR', 'label': 'WAR CS', 'classes': 'EU'}, position={'x': nan, 'y': nan})]
the nan values I guess make it impossible to render the graph. now what I would expect is an error message, but no error appears, simple nothing appears.
This was NOT the case when I first opened this issue since its the first time I try to manipulate position values. What I mean is that there are other type or errors not reported back
the nan values I guess make it impossible to render the graph.
Humm I wasn't aware of this kind of bug. I'll test it, thanks @joseberlines
Hey @joseberlines I think your problem is not related to what's described in this issue?
You can't use nan
like this in jsons, you should use 'null'
with quotes.
And if you use null in position, it means you're assigning no position to the nodes, so they won't show up in the screen.
My issue here is not about 'nan' vs 'null' is about the fact that if ipycytoscape does not interpret something because there is an error (nan in JSON) and does not through an error but just does not show anything. Then the user is confused. I would expect "error xy ipycytoscape can not interpret whatever".
In other words I know position={'x': nan, 'y': nan} is wrong, but then I would expect node / position JSON error etc etc.
Hm, I see.
I get the following when using nan
:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-13-9d015294f738> in <module>
----> 1 node1 = Node(data={'id': 'BER', 'label': 'BER Hbf', 'classes': 'east'}, position={'x': nan, 'y': 90})
NameError: name 'nan' is not defined
Maybe I'm reproducing your issue wrong. Could you please post a more complete example so I can maybe reproduce it?
I tried this:
[Node(data={'id': 'BER', 'label': '0.0-0.0', 'classes': 'east'}, position={'x': 0.0, 'y': 0.0}),
Node(data={'id': 'MUN', 'label': '10.0-5.0', 'classes': 'west'}, position={'x': 10.0, 'y': 5.0}),
Node(data={'id': 'FRA', 'label': '20.0-10.0', 'classes': 'west'}, position={'x': 20.0, 'y': 10.0}),
Node(data={'id': 'HAM', 'label': '30.0-15.0', 'classes': 'west'}, position={'x': 30.0, 'y': 15.0}),
Node(data={'id': 'LEP', 'label': '40.0-20.0', 'classes': 'east'}, position={'x': 40.0, 'y': 20.0}),
Node(data={'id': 'NUR', 'label': '50.0-25.0', 'classes': 'west'}, position={'x': 50.0, 'y': 25.0}),
Node(data={'id': 'PAR', 'label': '60.0-30.0', 'classes': 'EU'}, position={'x': 60.0, 'y': 30.0}),
Node(data={'id': 'MIL', 'label': '70.0-35.0', 'classes': 'EU'}, position={'x': 70.0, 'y': 35.0}),
Node(data={'id': 'BAR', 'label': 'nan-nan', 'classes': 'EU'}, position={'x': nan, 'y': nan}),
Node(data={'id': 'LYO', 'label': 'nan-nan', 'classes': 'EU'}, position={'x': nan, 'y': nan})]
no error. just nothing appears. If I Include all the ints:
[Node(data={'id': 'BER', 'label': '0.0-0.0', 'classes': 'east'}, position={'x': 0.0, 'y': 0.0}),
Node(data={'id': 'MUN', 'label': '10.0-5.0', 'classes': 'west'}, position={'x': 10.0, 'y': 5.0}),
Node(data={'id': 'FRA', 'label': '20.0-10.0', 'classes': 'west'}, position={'x': 20.0, 'y': 10.0}),
Node(data={'id': 'HAM', 'label': '30.0-15.0', 'classes': 'west'}, position={'x': 30.0, 'y': 15.0}),
Node(data={'id': 'LEP', 'label': '40.0-20.0', 'classes': 'east'}, position={'x': 40.0, 'y': 20.0}),
Node(data={'id': 'NUR', 'label': '50.0-25.0', 'classes': 'west'}, position={'x': 50.0, 'y': 25.0}),
Node(data={'id': 'PAR', 'label': '60.0-30.0', 'classes': 'EU'}, position={'x': 60.0, 'y': 30.0}),
Node(data={'id': 'MIL', 'label': '70.0-35.0', 'classes': 'EU'}, position={'x': 70.0, 'y': 35.0}),
Node(data={'id': 'BAR', 'label': '80.0-40.0', 'classes': 'EU'}, position={'x': 80.0, 'y': 40.0}),
Node(data={'id': 'LYO', 'label': '90.0-45.0', 'classes': 'EU'}, position={'x': 90.0, 'y': 45.0})]
result:
Is this still valid?
Say you are building a Graph node by node, edge by edge, style by style. NO error is raised in the building. then:
display(G)
and nothing appears. How to debug and look for the reason that makes for ipycytoscape not possible to display the graph?