示例#1
0
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.face_polygons(['x', 'y'])
示例#2
0
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)
示例#3
0
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"])
示例#4
0
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)
示例#5
0
def test_polygons():
    datasets_2d, specs = three_faces_sheet(zaxis=True)
    datasets = extrude(datasets_2d)
    eptm = Epithelium("3faces_3D", datasets, specs)
    eptm_2d = Epithelium("3faces_2D", datasets_2d, specs)

    dict_expected_res = {
        0: [
            [0.0, 0.0, 0.0],
            [1.0, 0.0, 0.0],
            [1.5, 0.86599999999999999, 0.0],
            [1.0, 1.732, 0.0],
            [0.0, 1.732, 0.0],
            [-0.5, 0.86599999999999999, 0.0],
        ],
        1: [
            [0.0, 0.0, 0.0],
            [-0.5, 0.86599999999999999, 0.0],
            [-1.5, 0.86599999999999999, 0.0],
            [-2.0, 0.0, 0.0],
            [-1.5, -0.86599999999999999, 0.0],
            [-0.5, -0.86599999999999999, 0.0],
        ],
        2: [
            [0.0, 0.0, 0.0],
            [-0.5, -0.86599999999999999, 0.0],
            [0.0, -1.732, 0.0],
            [1.0, -1.732, 0.0],
            [1.5, -0.86599999999999999, 0.0],
            [1.0, 0.0, 0.0],
        ],
        3: [
            [0.33333333333333331, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [-0.16666666666666666, 0.28866666666666663, 0.0],
            [0.0, 0.57733333333333325, 0.0],
            [0.33333333333333331, 0.57733333333333325, 0.0],
            [0.5, 0.28866666666666663, 0.0],
        ],
        4: [
            [-0.16666666666666666, 0.28866666666666663, 0.0],
            [0.0, 0.0, 0.0],
            [-0.16666666666666666, -0.28866666666666663, 0.0],
            [-0.5, -0.28866666666666663, 0.0],
            [-0.66666666666666663, 0.0, 0.0],
            [-0.5, 0.28866666666666663, 0.0],
        ],
        5: [
            [-0.16666666666666666, -0.28866666666666663, 0.0],
            [0.0, 0.0, 0.0],
            [0.33333333333333331, 0.0, 0.0],
            [0.5, -0.28866666666666663, 0.0],
            [0.33333333333333331, -0.57733333333333325, 0.0],
            [0.0, -0.57733333333333325, 0.0],
        ],
        6: [
            [1.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [0.33333333333333331, 0.0, 0.0],
        ],
        7: [
            [1.5, 0.86599999999999999, 0.0],
            [1.0, 0.0, 0.0],
            [0.33333333333333331, 0.0, 0.0],
            [0.5, 0.28866666666666663, 0.0],
        ],
        8: [
            [1.0, 1.732, 0.0],
            [1.5, 0.86599999999999999, 0.0],
            [0.5, 0.28866666666666663, 0.0],
            [0.33333333333333331, 0.57733333333333325, 0.0],
        ],
        9: [
            [0.0, 1.732, 0.0],
            [1.0, 1.732, 0.0],
            [0.33333333333333331, 0.57733333333333325, 0.0],
            [0.0, 0.57733333333333325, 0.0],
        ],
        10: [
            [-0.5, 0.86599999999999999, 0.0],
            [0.0, 1.732, 0.0],
            [0.0, 0.57733333333333325, 0.0],
            [-0.16666666666666666, 0.28866666666666663, 0.0],
        ],
        11: [
            [0.0, 0.0, 0.0],
            [-0.5, 0.86599999999999999, 0.0],
            [-0.16666666666666666, 0.28866666666666663, 0.0],
            [0.0, 0.0, 0.0],
        ],
        12: [
            [-0.5, 0.86599999999999999, 0.0],
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [-0.16666666666666666, 0.28866666666666663, 0.0],
        ],
        13: [
            [-1.5, 0.86599999999999999, 0.0],
            [-0.5, 0.86599999999999999, 0.0],
            [-0.16666666666666666, 0.28866666666666663, 0.0],
            [-0.5, 0.28866666666666663, 0.0],
        ],
        14: [
            [-2.0, 0.0, 0.0],
            [-1.5, 0.86599999999999999, 0.0],
            [-0.5, 0.28866666666666663, 0.0],
            [-0.66666666666666663, 0.0, 0.0],
        ],
        15: [
            [-1.5, -0.86599999999999999, 0.0],
            [-2.0, 0.0, 0.0],
            [-0.66666666666666663, 0.0, 0.0],
            [-0.5, -0.28866666666666663, 0.0],
        ],
        16: [
            [-0.5, -0.86599999999999999, 0.0],
            [-1.5, -0.86599999999999999, 0.0],
            [-0.5, -0.28866666666666663, 0.0],
            [-0.16666666666666666, -0.28866666666666663, 0.0],
        ],
        17: [
            [0.0, 0.0, 0.0],
            [-0.5, -0.86599999999999999, 0.0],
            [-0.16666666666666666, -0.28866666666666663, 0.0],
            [0.0, 0.0, 0.0],
        ],
        18: [
            [-0.5, -0.86599999999999999, 0.0],
            [0.0, 0.0, 0.0],
            [0.0, 0.0, 0.0],
            [-0.16666666666666666, -0.28866666666666663, 0.0],
        ],
        19: [
            [0.0, -1.732, 0.0],
            [-0.5, -0.86599999999999999, 0.0],
            [-0.16666666666666666, -0.28866666666666663, 0.0],
            [0.0, -0.57733333333333325, 0.0],
        ],
        20: [
            [1.0, -1.732, 0.0],
            [0.0, -1.732, 0.0],
            [0.0, -0.57733333333333325, 0.0],
            [0.33333333333333331, -0.57733333333333325, 0.0],
        ],
        21: [
            [1.5, -0.86599999999999999, 0.0],
            [1.0, -1.732, 0.0],
            [0.33333333333333331, -0.57733333333333325, 0.0],
            [0.5, -0.28866666666666663, 0.0],
        ],
        22: [
            [1.0, 0.0, 0.0],
            [1.5, -0.86599999999999999, 0.0],
            [0.5, -0.28866666666666663, 0.0],
            [0.33333333333333331, 0.0, 0.0],
        ],
        23: [
            [0.0, 0.0, 0.0],
            [1.0, 0.0, 0.0],
            [0.33333333333333331, 0.0, 0.0],
            [0.0, 0.0, 0.0],
        ],
    }

    expected_res = pd.Series(dict_expected_res)

    ## test standard on a 3d-epithelium

    res = eptm.face_polygons(["x", "y", "z"])
    assert all([(expected_res[i] == res[i]).all()
                for i in range(res.shape[0])])