Exemple #1
0
def test_file_write():
    """Tests that files are written correctly."""
    files = sorted(glob.glob("*.feather"))
    for f in sorted(files):
        os.remove(f)

    nbr = nbrhood.NeighborhoodFeatures(url=url,
                                       radius=1,
                                       offset=[15, 15, 15],
                                       segment_url=url_seg)
    nbr.fit([2], 5, file_path="test", batch_size=10)

    files = sorted(glob.glob("*.feather"))
    for f in sorted(files):
        print(f)
        os.remove(f)
    assert files == ["test0_10_2_4.feather"]

    df_nbr = nbr.fit([2],
                     5,
                     file_path="test",
                     batch_size=10,
                     start_seg=2,
                     start_vert=0)
    files = sorted(glob.glob("*.feather"))
    for f in sorted(files):
        os.remove(f)
    assert files == ["test0_10_2_4.feather"]
Exemple #2
0
def test_init_bad_inputs():
    """Tests that proper errors are raised when bad inputs are given to __init__ method."""
    with pytest.raises(TypeError):
        nbrhood.NeighborhoodFeatures(url=0, radius=SIZE, offset=OFF)
    with pytest.raises(NotImplementedError):
        nbrhood.NeighborhoodFeatures(url="asdf", radius=SIZE, offset=OFF)
    with pytest.raises(TypeError):
        nbrhood.NeighborhoodFeatures(url=url, radius=0.5, offset=OFF)
    with pytest.raises(ValueError):
        nbrhood.NeighborhoodFeatures(url=url,
                                     radius=-1,
                                     offset=OFF,
                                     segment_url=url_seg)
    with pytest.raises(TypeError):
        nbrhood.NeighborhoodFeatures(url=url,
                                     radius=SIZE,
                                     offset=12,
                                     segment_url=url_seg)
    with pytest.raises(TypeError):
        nbrhood.NeighborhoodFeatures(url=url,
                                     radius=SIZE,
                                     offset=OFF,
                                     segment_url=0)
    with pytest.raises(NotImplementedError):
        nbrhood.NeighborhoodFeatures(url=url,
                                     radius=SIZE,
                                     offset=OFF,
                                     segment_url="asdf")
def gen_array():
    nbr = nbrhood.NeighborhoodFeatures(url=url,
                                       radius=SIZE,
                                       offset=[15, 15, 15],
                                       segment_url=url_seg)
    df_nbr = nbr.fit([2], 5)
    ind = SIZE * 2 + 1
    arr = df_nbr.iloc[2, 3:].values.reshape((ind, ind, ind))
    return arr
Exemple #4
0
def test_neighborhood():
    """Tests that neighborhood data is generated correctly."""
    nbr = nbrhood.NeighborhoodFeatures(url=url,
                                       radius=1,
                                       offset=[15, 15, 15],
                                       segment_url=url_seg)
    df_nbr = nbr.fit([2], 5)
    assert df_nbr.shape == (10, 30)  # 5on, 5off for each swc
    assert not df_nbr.empty
Exemple #5
0
def test_fit_bad_inputs():
    """Tests that proper errors are raised when bad inputs are given to fit method."""
    nbr = nbrhood.NeighborhoodFeatures(url=url,
                                       radius=SIZE,
                                       offset=[15, 15, 15],
                                       segment_url=url_seg)
    with pytest.raises(TypeError):
        nbr.fit(seg_ids=1, num_verts=5, file_path="demo", batch_size=1000)
    with pytest.raises(cloudvolume.exceptions.SkeletonDecodeError):
        nbr.fit(seg_ids=[1], num_verts=5, file_path="demo", batch_size=1000)