Skip to content

Commit

Permalink
update test with new names
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud committed Nov 14, 2024
1 parent d11a6b0 commit 6cbd633
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 12 deletions.
42 changes: 40 additions & 2 deletions tests/test_closing_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@
cle.select_device("TX")


def test_close_box_old():
gpu_input = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 2, 0],
[1, 1, 1, 0, 2, 0],
[0, 0, 0, 0, 2, 0],
[3, 0, 0, 0, 0, 0],
]
)
)

gpu_reference = cle.push(
np.asarray(
[
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 1, 2, 2],
[1, 1, 1, 1, 2, 2],
[1, 0, 0, 0, 2, 2],
[3, 0, 0, 0, 2, 2],
]
)
)

gpu_output = cle.closing_box(gpu_input, radius_x=1, radius_y=1)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)

print(a)
print(b)

assert np.array_equal(a, b)


def test_close_box_2d():
gpu_input = cle.push(
np.asarray(
Expand Down Expand Up @@ -32,7 +70,7 @@ def test_close_box_2d():
)
)

gpu_output = cle.closing(gpu_input, radius_x=1, radius_y=1)
gpu_output = cle.grayscale_closing(gpu_input, radius_x=1, radius_y=1)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down Expand Up @@ -91,7 +129,7 @@ def test_close_box_3d():
)
)

gpu_output = cle.closing(gpu_input, radius_x=1, radius_y=1)
gpu_output = cle.grayscale_closing(gpu_input, radius_x=1, radius_y=1)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down
46 changes: 44 additions & 2 deletions tests/test_closing_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@
cle.select_device("TX")


def test_close_sphere_old():
gpu_input = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 2, 0],
[1, 1, 1, 0, 2, 0],
[0, 0, 0, 0, 2, 0],
[3, 0, 0, 0, 0, 0],
]
)
)

gpu_reference = cle.push(
np.asarray(
[
[1, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 1, 2, 0],
[1, 1, 1, 1, 2, 2],
[1, 1, 0, 0, 2, 0],
[3, 0, 0, 0, 0, 0],
]
)
)

gpu_output = cle.closing_sphere(gpu_input, radius_x=1, radius_y=1)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)

print(a)
print(b)

assert np.array_equal(a, b)


def test_close_sphere_2d():
gpu_input = cle.push(
np.asarray(
Expand Down Expand Up @@ -32,7 +70,9 @@ def test_close_sphere_2d():
)
)

gpu_output = cle.closing(gpu_input, radius_x=1, radius_y=1, connectivity="sphere")
gpu_output = cle.grayscale_closing(
gpu_input, radius_x=1, radius_y=1, connectivity="sphere"
)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down Expand Up @@ -91,7 +131,9 @@ def test_close_sphere_3d():
)
)

gpu_output = cle.closing(gpu_input, radius_x=1, radius_y=1, connectivity="sphere")
gpu_output = cle.grayscale_closing(
gpu_input, radius_x=1, radius_y=1, connectivity="sphere"
)

a = cle.pull(gpu_output)
b = cle.pull(gpu_reference)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_detect_maxima_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ def test_detect_maxima_box():
print(b)

assert np.array_equal(a, b)


test_detect_maxima_box()
37 changes: 36 additions & 1 deletion tests/test_dilate_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
cle.select_device("TX")


def test_dilate_old():
test = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
]
)
)

reference = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
]
)
)

result = cle.create(test)
cle.dilate_box(test, result)

print(result)

a = cle.pull(result)
b = cle.pull(reference)
assert np.array_equal(a, b)


def test_dilate():
test = cle.push(
np.asarray(
Expand All @@ -31,7 +66,7 @@ def test_dilate():
)

result = cle.create(test)
cle.dilate(test, result)
cle.binary_dilate(test, result)

print(result)

Expand Down
37 changes: 36 additions & 1 deletion tests/test_dilate_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
cle.select_device("TX")


def test_dilate_sphere_old():
test = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
]
)
)

reference = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 1, 1, 1, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
]
)
)

result = cle.create(test)
cle.dilate_sphere(test, result)

print(result)

a = cle.pull(result)
b = cle.pull(reference)
assert np.array_equal(a, b)


def test_dilate_sphere():
test = cle.push(
np.asarray(
Expand All @@ -31,7 +66,7 @@ def test_dilate_sphere():
)

result = cle.create(test)
cle.dilate(test, result, "sphere")
cle.binary_dilate(test, result, connectivity="sphere")

print(result)

Expand Down
37 changes: 36 additions & 1 deletion tests/test_erode_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
cle.select_device("TX")


def test_erode_box_old():
test = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
]
)
)

reference = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
]
)
)

result = cle.create(test)
cle.erode_box(test, result)

print(result)

a = cle.pull(result)
b = cle.pull(reference)
assert np.array_equal(a, b)


def test_erode_box():
test = cle.push(
np.asarray(
Expand All @@ -31,7 +66,7 @@ def test_erode_box():
)

result = cle.create(test)
cle.erode(test, result)
cle.binary_erode(test, result)

print(result)

Expand Down
37 changes: 36 additions & 1 deletion tests/test_erode_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
cle.select_device("TX")


def test_erode_sphere_old():
test = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
]
)
)

reference = cle.push(
np.asarray(
[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
]
)
)

result = cle.create(test)
cle.erode_sphere(test, result)

print(result)

a = cle.pull(result)
b = cle.pull(reference)
assert np.array_equal(a, b)


def test_erode_sphere():
test = cle.push(
np.asarray(
Expand All @@ -31,7 +66,7 @@ def test_erode_sphere():
)

result = cle.create(test)
cle.erode(test, result, "sphere")
cle.binary_erode(test, result, connectivity="sphere")

print(result)

Expand Down
Loading

0 comments on commit 6cbd633

Please sign in to comment.