def test_chord_constructor_self_reference(self): chord = Chord([('A', 'B', 2), ('B', 'A', 3), ('A', 'A', 2)]) nodes = np.array( [[-0.5, 0.866025, 0], [0.5, -0.866025, 1]] ) self.assertEqual(chord.nodes, Nodes(nodes))
def test_trimesh_constructor_df_nodes(self): nodes_df = util.pd.DataFrame(self.nodes, columns=['x', 'y', 'z']) trimesh = TriMesh((self.simplices, nodes_df)) nodes = Nodes([(0, 0, 0, 0), (0.5, 1, 1, 1), (1., 0, 2, 2), (1.5, 1, 3, 4)], vdims='z') self.assertEqual(trimesh.array(), np.array(self.simplices)) self.assertEqual(trimesh.nodes, nodes)
def test_chord_constructor_with_vdims(self): chord = Chord(self.simplices, vdims=['z']) nodes = np.array([[0.9396926207859084, 0.3420201433256687, 0], [6.123233995736766e-17, 1.0, 1], [-0.8660254037844388, -0.4999999999999998, 2], [0.7660444431189779, -0.6427876096865396, 3]]) self.assertEqual(chord.nodes, Nodes(nodes)) self.assertEqual(chord.array(), np.array(self.simplices))
def test_chord_constructor_no_vdims(self): chord = Chord(self.simplices) nodes = np.array([[0.8660254037844387, 0.49999999999999994, 0], [-0.4999999999999998, 0.8660254037844388, 1], [-0.5000000000000004, -0.8660254037844384, 2], [0.8660254037844379, -0.5000000000000012, 3]]) self.assertEqual(chord.nodes, Nodes(nodes)) self.assertEqual(chord.array(), np.array([s[:2] for s in self.simplices]))
def test_constructor_with_nodes(self): graph = Graph(((self.source, self.target), self.nodes)) nodes = Nodes(self.nodes) self.assertEqual(graph.nodes, nodes)
def test_basic_constructor(self): graph = Graph(((self.source, self.target), )) nodes = Nodes(self.nodes) self.assertEqual(graph.nodes, nodes)
def test_constructor_with_nodes_and_paths(self): paths = Graph(((self.source, self.target), self.nodes)).edgepaths graph = Graph(((self.source, self.target), self.nodes, paths.data)) nodes = Nodes(self.nodes) self.assertEqual(graph._edgepaths, paths)