def test_polygons(): datasets_2d, specs = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, scale=1 / 3.0) eptm = Epithelium("3faces_3D", datasets, specs) RNRGeometry.update_all(eptm) with raises(ValueError): fp = eptm.face_polygons() eptm.reset_index(order=True) res = eptm.face_polygons(["x", "y", "z"]) shapes = res.apply(lambda s: s.shape in ((6, 3), (4, 3))) assert all(shapes)
def test_face_polygons_exception(): datasets = {} tri_verts = [[0, 0], [1, 0], [-0.5, 3**0.5 / 2], [-0.5, -(3**0.5) / 2]] tri_edges_valid = [ [0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 0, 2], ] tri_edges_invalid = [ [0, 1, 0], [1, 2, 0], [2, 0, 0], [0, 3, 1], [3, 1, 1], [1, 0, 1], [0, 2, 2], [2, 3, 2], [3, 1, 2], ] # changed 0 to 1 to create an invalid face datasets["edge"] = pd.DataFrame(data=np.array(tri_edges_valid), columns=["srce", "trgt", "face"]) datasets["edge"].index.name = "edge" datasets["face"] = pd.DataFrame(data=np.zeros((3, 2)), columns=["x", "y"]) datasets["face"].index.name = "face" datasets["vert"] = pd.DataFrame(data=np.array(tri_verts), columns=["x", "y"]) datasets["vert"].index.name = "vert" specs = config.geometry.planar_spec() eptm = Epithelium("valid", datasets, specs, coords=["x", "y"]) PlanarGeometry.update_all(eptm) eptm.reset_index(order=True) eptm.face_polygons(["x", "y"])
def test_polygons(): datasets_2d, specs = three_faces_sheet(zaxis=True) datasets = extrude(datasets_2d, scale=1 / 3.0) eptm = Epithelium("3faces_3D", datasets, specs) RNRGeometry.update_all(eptm) with raises(ValueError): fp = eptm.face_polygons() eptm.reset_index(order=True) expected_res = [ [ [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.5, 0.866, 0.0], [1.0, 1.732, 0.0], [0.0, 1.732, 0.0], [-0.5, 0.866, 0.0], ], [ [-1.5, -0.866, 0.0], [-0.5, -0.866, 0.0], [0.0, 0.0, 0.0], [-0.5, 0.866, 0.0], [-1.5, 0.866, 0.0], [-2.0, 0.0, 0.0], ], [ [0.0, -1.732, 0.0], [1.0, -1.732, 0.0], [1.5, -0.866, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [-0.5, -0.866, 0.0], ], [ [0.0, 0.0, 0.0], [0.33333333, 0.0, 0.0], [0.5, 0.28866667, 0.0], [0.33333333, 0.57733333, 0.0], [0.0, 0.57733333, 0.0], [-0.16666667, 0.28866667, 0.0], ], [ [-0.5, -0.28866667, 0.0], [-0.16666667, -0.28866667, 0.0], [0.0, 0.0, 0.0], [-0.16666667, 0.28866667, 0.0], [-0.5, 0.28866667, 0.0], [-0.66666667, 0.0, 0.0], ], [ [0.0, -0.57733333, 0.0], [0.33333333, -0.57733333, 0.0], [0.5, -0.28866667, 0.0], [0.33333333, 0.0, 0.0], [0.0, 0.0, 0.0], [-0.16666667, -0.28866667, 0.0], ], [[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.33333333, 0.0, 0.0]], [ [0.5, 0.28866667, 0.0], [0.33333333, 0.0, 0.0], [1.0, 0.0, 0.0], [1.5, 0.866, 0.0], ], [ [0.33333333, 0.57733333, 0.0], [0.5, 0.28866667, 0.0], [1.5, 0.866, 0.0], [1.0, 1.732, 0.0], ], [ [0.0, 0.57733333, 0.0], [0.33333333, 0.57733333, 0.0], [1.0, 1.732, 0.0], [0.0, 1.732, 0.0], ], [ [-0.5, 0.866, 0.0], [-0.16666667, 0.28866667, 0.0], [0.0, 0.57733333, 0.0], [0.0, 1.732, 0.0], ], [ [0.0, 0.0, 0.0], [-0.16666667, 0.28866667, 0.0], [0.0, 0.0, 0.0], [-0.5, 0.866, 0.0], ], [ [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [-0.16666667, 0.28866667, 0.0], [-0.5, 0.866, 0.0], ], [ [-0.5, 0.28866667, 0.0], [-0.16666667, 0.28866667, 0.0], [-0.5, 0.866, 0.0], [-1.5, 0.866, 0.0], ], [ [-2.0, 0.0, 0.0], [-0.66666667, 0.0, 0.0], [-0.5, 0.28866667, 0.0], [-1.5, 0.866, 0.0], ], [ [-1.5, -0.866, 0.0], [-0.5, -0.28866667, 0.0], [-0.66666667, 0.0, 0.0], [-2.0, 0.0, 0.0], ], [ [-1.5, -0.866, 0.0], [-0.5, -0.866, 0.0], [-0.16666667, -0.28866667, 0.0], [-0.5, -0.28866667, 0.0], ], [ [-0.5, -0.866, 0.0], [0.0, 0.0, 0.0], [-0.16666667, -0.28866667, 0.0], [0.0, 0.0, 0.0], ], [ [-0.5, -0.866, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [-0.16666667, -0.28866667, 0.0], ], [ [0.0, -1.732, 0.0], [0.0, -0.57733333, 0.0], [-0.16666667, -0.28866667, 0.0], [-0.5, -0.866, 0.0], ], [ [0.0, -1.732, 0.0], [1.0, -1.732, 0.0], [0.33333333, -0.57733333, 0.0], [0.0, -0.57733333, 0.0], ], [ [1.0, -1.732, 0.0], [1.5, -0.866, 0.0], [0.5, -0.28866667, 0.0], [0.33333333, -0.57733333, 0.0], ], [ [1.5, -0.866, 0.0], [1.0, 0.0, 0.0], [0.33333333, 0.0, 0.0], [0.5, -0.28866667, 0.0], ], [[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.33333333, 0.0, 0.0], [0.0, 0.0, 0.0]], ] expected_res = [np.array(poly) for poly in expected_res] res = eptm.face_polygons(["x", "y", "z"]) for i in range(res.shape[0]): np.testing.assert_almost_equal(expected_res[i], res[i], decimal=4)