def test_compute_2(self): # should respect the maxPos option nodes = [ Node(1, 50), Node(2, 50), Node(3, 50), Node(3, 50), Node(3, 50), Node(304, 50), Node(454, 50), Node(454, 50), Node(454, 50), Node(804, 50), Node(804, 70), Node(804, 50), Node(804, 50), Node(854, 50), Node(854, 50), ] force = Force({"maxPos": 904}) force.nodes(nodes) force.compute() for node in nodes: self.assertLessEqual(node.currentRight(), 904)
def test_compute_3(self): # should respect the minPos option nodes = [ Node(1, 50), Node(2, 50), Node(3, 50), Node(3, 50), Node(3, 50), Node(304, 50), Node(454, 50), Node(454, 50), Node(454, 50), Node(804, 50), Node(804, 70), Node(804, 50), Node(804, 50), Node(854, 50), Node(854, 50), ] force = Force({"minPos": 30}) force.nodes(nodes) force.compute() for node in nodes: self.assertGreater(node.currentRight(), 30) # is this right? self.assertGreaterEqual(node.currentLeft(), 30)
def compute(self): nodes = self.get_nodes() if self.direction in ["left", "right"]: nodeHeight = max((n.w for n in nodes)) else: nodeHeight = max((n.h for n in nodes)) renderer = Renderer({ "nodeHeight": nodeHeight, "layerGap": self.options["layerGap"], "direction": self.options["direction"], }) renderer.layout(nodes) force = Force(self.options["labella"]) force.nodes(nodes) force.compute() newnodes = force.nodes() renderer.layout(newnodes) return newnodes, renderer
def compute(self): nodes = self.get_nodes() if self.direction in ['left', 'right']: nodeHeight = max((n.w for n in nodes)) else: nodeHeight = max((n.h for n in nodes)) renderer = Renderer({ 'nodeHeight': nodeHeight, 'layerGap': self.options['layerGap'], 'direction': self.options['direction'] }) renderer.layout(nodes) force = Force(self.options['labella']) force.nodes(nodes) force.compute() newnodes = force.nodes() renderer.layout(newnodes) return newnodes, renderer
def test_compute_1(self): # should find location for the nodes that make them not overlap nodes = [ Node(1, 50), Node(2, 50), Node(3, 50), Node(3, 50), Node(3, 50), Node(304, 50), Node(454, 50), Node(454, 50), Node(454, 50), Node(804, 50), Node(804, 70), Node(804, 50), Node(804, 50), Node(854, 50), Node(854, 50), ] force = Force() force.nodes(nodes) force.compute() current_pos = [n.currentPos for n in nodes] expected_pos = [ 25, 78, 131, 184, 237, 304, 401, 454, 507, 673, 736, 799, 852, 905, 958, ] self.assertEqual(current_pos, expected_pos)
def test_nodes(self): force = Force() # it should return current value when called without argument self.assertEqual(force.nodes(), []) force.nodes([1]) self.assertEqual(force.nodes(), [1]) # it should set value when called with an argument force.nodes([1]) self.assertEqual(force.nodes(), [1])