Ejemplo n.º 1
0
def test_flood_fill_whole():
    fail_message = 'Flood fill failed to fill whole volume.'
    shape = (10, 10, 10)
    example2 = np.zeros(shape, dtype=np.int)
    example2[5, 5, 5] = 0
    t7 = opt.flood_fill(example2, (5, 5, 5), [0], None, False)
    assert_equal(len(t7), (example2 == 0).sum(), fail_message)
Ejemplo n.º 2
0
def test_flood_fill_whole():
    fail_message = 'Flood fill failed to fill whole volume.'
    shape = (10,10,10)
    example2 = np.zeros(shape, dtype=np.int)
    example2[5,5,5] = 0
    t7 = opt.flood_fill(example2, (5,5,5), [0], None, False)
    assert_equal(len(t7), (example2==0).sum(), fail_message)
Ejemplo n.º 3
0
def test_flood_fill_with_coordinates():
    fail_message = 'Flood fill failed with coordinate return'
    t = opt.flood_fill(_flood_fill_example(), (0, 0, 0), [0], None, False)
    assert_equal(
        set(map(tuple, t.tolist())),
        set([(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 2, 1), (1, 0, 0),
             (1, 0, 1)]), fail_message)
Ejemplo n.º 4
0
def test_flood_fill_pipes():
    fail_message = 'Flood fill failed with thin columns in large volume.'
    example3 = np.random.randint(6, size=(200,200,200))
    example3[2,2,:] = 6
    example3[:,2,150] = 6
    example3[45,:,:] = 6
    t8 = opt.flood_fill(example3, (2,2,0), [6], None, True)
    assert_equal(len(t8), (example3==6).sum(), fail_message)
Ejemplo n.º 5
0
def test_flood_fill_pipes():
    fail_message = 'Flood fill failed with thin columns in large volume.'
    example3 = np.random.randint(6, size=(200, 200, 200))
    example3[2, 2, :] = 6
    example3[:, 2, 150] = 6
    example3[45, :, :] = 6
    t8 = opt.flood_fill(example3, (2, 2, 0), [6], None, True)
    assert_equal(len(t8), (example3 == 6).sum(), fail_message)
Ejemplo n.º 6
0
def test_flood_fill_multiple_acceptable():
    fail_message = 'Flood fill failed to flood with multiple acceptable labels'
    t1 = opt.flood_fill(_flood_fill_example(), (1,1,1), [1,4], None, True)
    assert_equal(set(t1), set([8,10,16,17,18,20,22]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0,1,2), [2,5], None, True)
    assert_equal(set(t2), set([2,3,6,11,14,15,19,23]), fail_message)
Ejemplo n.º 7
0
def test_flood_fill_with_coordinates():
    fail_message = 'Flood fill failed with coordinate return'
    t = opt.flood_fill(_flood_fill_example(), (0,0,0), [0], None, False)
    assert_equal(set(map(tuple, t.tolist())), set([(0,0,0), (0,1,0), (0,1,1), (0,2,1), (1,0,0),
                            (1,0,1)]), fail_message)
Ejemplo n.º 8
0
def test_flood_fill_with_no_hits():
    fail_message = 'Flood fill failed with mismatching first label.'
    t = opt.flood_fill(_flood_fill_example(), (0,1,3), [2], None, True)
    assert_equal(set(t), set([]), fail_message)
Ejemplo n.º 9
0
def test_flood_fill_basic():
    fail_message = 'Flood fill failed to find all matching labels.'
    t1 = opt.flood_fill(_flood_fill_example(), (0,0,0), [0], None, True)
    assert_equal(set(t1), set([0,4,5,9,12,13]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0,0,3), [5], None, True)
    assert_equal(set(t2), set([3,14,15,19,23]), fail_message)
Ejemplo n.º 10
0
def test_flood_fill_multiple_acceptable():
    fail_message = 'Flood fill failed to flood with multiple acceptable labels'
    t1 = opt.flood_fill(_flood_fill_example(), (1, 1, 1), [1, 4], None, True)
    assert_equal(set(t1), set([8, 10, 16, 17, 18, 20, 22]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0, 1, 2), [2, 5], None, True)
    assert_equal(set(t2), set([2, 3, 6, 11, 14, 15, 19, 23]), fail_message)
Ejemplo n.º 11
0
def test_flood_fill_with_no_hits():
    fail_message = 'Flood fill failed with mismatching first label.'
    t = opt.flood_fill(_flood_fill_example(), (0, 1, 3), [2], None, True)
    assert_equal(set(t), set([]), fail_message)
Ejemplo n.º 12
0
def test_flood_fill_basic():
    fail_message = 'Flood fill failed to find all matching labels.'
    t1 = opt.flood_fill(_flood_fill_example(), (0, 0, 0), [0], None, True)
    assert_equal(set(t1), set([0, 4, 5, 9, 12, 13]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0, 0, 3), [5], None, True)
    assert_equal(set(t2), set([3, 14, 15, 19, 23]), fail_message)