Fixed bugs so test pass now

This commit is contained in:
Matěj Týč
2014-11-11 00:39:49 +01:00
parent 53f93a7f8e
commit 438a9355d6
2 changed files with 19 additions and 25 deletions
+9 -7
View File
@@ -137,7 +137,7 @@ cdef shape_info get_shape_info(inarr_shape):
res.DEX[D_ei] = res.DEX[D_ef] - res.DEX[D_eb] # DEX[D_eb] = one row up, remember?
res.DEX[D_ej] = res.DEX[D_ei] + 1
res.DEX[D_ek] = res.DEX[D_ei] + 2
res.DEX[D_el] = res.DEX[D_ei] - 2 * res.DEX[D_eb]
res.DEX[D_el] = res.DEX[D_ei] - res.DEX[D_eb]
res.DEX[D_em] = res.DEX[D_el] + 1
res.DEX[D_en] = res.DEX[D_el] + 2
@@ -470,7 +470,7 @@ cdef void scan2D(DTYPE_t *data_p, DTYPE_t *forest_p, shape_info *shapeinfo,
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_eb])
if neighbors == 8:
if x < shapeinfo.x - 1:
if x + 1 < shapeinfo.x:
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_ec])
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_ed])
@@ -557,7 +557,7 @@ cdef void scan3D(DTYPE_t *data_p, DTYPE_t *forest_p, shape_info *shapeinfo,
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_eb])
if neighbors == 8:
if x < shapeinfo.x - 1:
if x + 1 < shapeinfo.x:
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_ec])
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_ed])
@@ -579,9 +579,11 @@ cdef void scan3D(DTYPE_t *data_p, DTYPE_t *forest_p, shape_info *shapeinfo,
if x + 1 < shapeinfo.x:
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_ek])
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_el])
if y + 1 < shapeinfo.y:
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_el])
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_em])
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_em])
if x + 1 < shapeinfo.x:
join_trees_wrapper(data_p, forest_p, rindex, DEX[D_en])
if x + 1 < shapeinfo.x:
join_trees_wrapper(data_p, forest_p,
rindex, DEX[D_en])
+10 -18
View File
@@ -76,7 +76,8 @@ class TestConnectedComponents:
[0, 0, 6],
[5, 5, 5]])
assert_array_equal(label(x, background=0),
res = label(x, background=0)
assert_array_equal(res,
[[-1, -1, 0],
[-1, -1, 0],
[+1, 1, 1]])
@@ -132,16 +133,16 @@ class TestConnectedComponents3d:
[0, 1, 1, 3, 3],
[1, 5, 1, 1, 7]])
self.labels[2] = np.array([[1, 1, 8, 8, 10],
[9, 1, 4, 8, 8],
[9, 1, 7, 8, 7],
[9, 5, 7, 7, 7]])
self.labels[2] = np.array([[1, 1, 8, 8, 9],
[10, 1, 4, 8, 8],
[10, 1, 7, 8, 7],
[10, 5, 7, 7, 7]])
def test_basic(self):
labels = label(self.x)
assert_array_equal(labels, self.labels)
assert self.x[0, 0, 2] == 3, \
assert self.x[0, 0, 2] == 2, \
"Data was modified!"
def test_random(self):
@@ -218,7 +219,8 @@ class TestConnectedComponents3d:
[1, BGL, BGL],
[BGL, BGL, BGL]])
assert_array_equal(label(x, background=0), lb)
res = label(x, background=0)
assert_array_equal(res, lb)
def test_background_one_region_center(self):
x = np.zeros((3, 3, 3), int)
@@ -241,14 +243,4 @@ class TestConnectedComponents3d:
if __name__ == "__main__":
#run_module_suite()
lol = TestConnectedComponents3d()
lol.setup()
lol.test_basic() # 1 failiure
lol.test_random()
#lol.test_diag() # epic failiure
#lol.test_4_vs_8() # label8 epic
#lol.test_background()
#lol.test_background_two_regions()
lol.test_background_one_region_center()
lol.test_return_num()
run_module_suite()