Skip to content

Commit

Permalink
made required fixes for python3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Giancarlo Perrone committed May 10, 2018
1 parent 1f29761 commit 03dfa78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyvis/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def add_nodes(self, nodes, **kwargs):

nd = defaultdict(dict)
for i in range(len(nodes)):
for k, v in kwargs.iteritems():
for k, v in kwargs.items():
assert(
len(v) == len(nodes)
), "keyword arg %s [length %s] does not match" \
Expand Down
6 changes: 4 additions & 2 deletions pyvis/options.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from physics import *

try:
from physics import *
except:
from .physics import *

class EdgeOptions(object):

Expand Down
16 changes: 8 additions & 8 deletions pyvis/tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def test_node_labels(self):
self.g.add_node(1, "n2")
self.g.add_node(2, "n3")
self.g.add_node(3, "n4")
self.assertEqual(map(lambda s: s["label"], self.g.nodes), [
"n2", "n3", "n4"])
self.assertEqual(set(map(lambda s: s["label"], self.g.nodes)),
set(["n2", "n3", "n4"]))

def test_node_titles(self):
self.g.add_nodes(range(10))
Expand All @@ -50,7 +50,7 @@ def test_node_titles(self):
n["title"] = "node #" + str(n["id"])

ref = ["node #" + str(i) for i in range(10)]
self.assertEqual(map(lambda s: s["title"], self.g.nodes), ref)
self.assertEqual(set(map(lambda s: s["title"], self.g.nodes)), set(ref))

def test_node_sizes(self):
self.g.add_nodes(range(10))
Expand All @@ -59,7 +59,7 @@ def test_node_sizes(self):
n["size"] = n["id"] * 2

ref = [i * 2 for i in range(10)]
self.assertEqual(map(lambda s: s["size"], self.g.nodes), ref)
self.assertEqual(set(map(lambda s: s["size"], self.g.nodes)), set(ref))

def test_adding_nodes(self):
g = self.g
Expand Down Expand Up @@ -176,8 +176,8 @@ def test_add_edges_weights(self):
for edges in self.g.edges:
self.assertTrue("width" in edges)
self.assertEqual(
[1, 2, 3, 4, 5, 6],
map(lambda x: x["width"], self.g.edges))
list([1, 2, 3, 4, 5, 6]),
list(map(lambda x: x["width"], self.g.edges)))

def test_add_edges_mixed_weights(self):
self.g.add_edges(
Expand All @@ -192,8 +192,8 @@ def test_add_edges_mixed_weights(self):
self.assertEqual(self.g.neighbors(2), set([0, 1, 3]))
self.assertEqual(self.g.neighbors(3), set([0, 1, 2]))
self.assertEqual(
[1, None, 3, None, 5, None],
map(lambda x: x.get("width", None), self.g.edges))
list([1, None, 3, None, 5, None]),
list(map(lambda x: x.get("width", None), self.g.edges)))

def test_add_edge_directed(self):
self.g.directed = True
Expand Down

0 comments on commit 03dfa78

Please sign in to comment.