Example #1
0
def test_cut_out():
    datasets_2d, specs = three_faces_sheet()
    datasets = extrude(datasets_2d, method='translation')

    eptm = Epithelium('3faces_3D', datasets)
    eptm_ordered = eptm.copy(deep_copy=True)

    bounding_box_xy = np.array([[-1., 10.], [-1.5, 1.5]])
    bounding_box_yx = np.array([[-1.5, 1.5], [-1.0, 10.]])
    bounding_box_xyz = np.array([[-10., 10.], [-1.5, 10.], [-2., 1.]])

    expected_index_xy = pd.Index([ 2,  3,  4,  7,  8,  9, 10, 13, 14, 15,\
                                   20, 21, 22, 25, 26, 27, 28, 31, 32, \
                                   33, 44, 46, 47, 48, 49, 50, 51, 52, \
                                   53, 54, 64, 66, 67, 68, 69, 70, 71, \
                                   72, 73, 74, 75, 76, 77, 78, 88, 90, \
                                   91, 92, 93, 94, 95, 96, 97, 98],\
                                 name='edge',dtype='int64')

    expected_index_xyz = pd.Index([13, 14, 15, 31, 32, 33, 88, 90, 91, \
                                   92, 93, 94, 95, 96, 97, 98],\
                                  name='edge',dtype='int64')

    # test 2-coords, ordered
    res = eptm.cut_out(bbox=bounding_box_xy, coords=['x', 'y'])
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()

    # test 2-coords, inverse order
    res = eptm.cut_out(bbox=bounding_box_yx, coords=['y', 'x'])
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()

    # test 3-coords
    res = eptm.cut_out(bbox=bounding_box_xyz, coords=['x', 'y', 'z'])
    assert len(res) == len(expected_index_xyz)
    assert (res == expected_index_xyz).all()

    # test default coords argument
    res = eptm.cut_out(bbox=bounding_box_xy)
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()
Example #2
0
def test_cut_out():
    datasets_2d, _ = three_faces_sheet()
    datasets = extrude(datasets_2d, method="translation")

    eptm = Epithelium("3faces_3D", datasets)

    bounding_box_xy = np.array([[-1.0, 10.0], [-1.5, 1.5]])
    bounding_box_yx = np.array([[-1.5, 1.5], [-1.0, 10.0]])
    bounding_box_xyz = np.array([[-10.0, 10.0], [-1.5, 10.0], [-2.0, 1.0]])

    expected_index_xy = pd.Index(
        [
            2,
            3,
            4,
            7,
            8,
            9,
            10,
            13,
            14,
            15,
            20,
            21,
            22,
            25,
            26,
            27,
            28,
            31,
            32,
            33,
            44,
            46,
            47,
            48,
            49,
            50,
            51,
            52,
            53,
            54,
            64,
            66,
            67,
            68,
            69,
            70,
            71,
            72,
            73,
            74,
            75,
            76,
            77,
            78,
            88,
            90,
            91,
            92,
            93,
            94,
            95,
            96,
            97,
            98,
        ],
        name="edge",
        dtype="int64",
    )

    expected_index_xyz = pd.Index(
        [13, 14, 15, 31, 32, 33, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98],
        name="edge",
        dtype="int64",
    )

    # test 2-coords, ordered
    res = eptm.cut_out(bbox=bounding_box_xy, coords=["x", "y"])
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()

    # test 2-coords, inverse order
    res = eptm.cut_out(bbox=bounding_box_yx, coords=["y", "x"])
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()

    # test 3-coords
    res = eptm.cut_out(bbox=bounding_box_xyz, coords=["x", "y", "z"])
    assert len(res) == len(expected_index_xyz)
    assert (res == expected_index_xyz).all()

    # test default coords argument
    res = eptm.cut_out(bbox=bounding_box_xy)
    assert len(res) == len(expected_index_xy)
    assert (res == expected_index_xy).all()