Skip to content

Commit

Permalink
feat: delete tests of deleted functions
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrink committed Nov 16, 2023
1 parent 45e0b97 commit 99d1b38
Showing 1 changed file with 4 additions and 109 deletions.
113 changes: 4 additions & 109 deletions tests/test_mask_expansion.py
Original file line number Diff line number Diff line change
@@ -1,84 +1,12 @@
import numpy as np
from decimer_segmentation.complete_structure import (
get_bounding_box_center,
get_edge_line,
get_euklidian_distance,
set_x_range,
get_next_pixel_to_check,
adapt_x_values,
get_contour_seeds,
get_mask_center,
get_seeds,
get_neighbour_pixels,
expand_masks,
expansion_coordination,
detect_horizontal_and_vertical_lines,
)


def test_get_bounding_box_center():
# Determine the center of a given polygon bounding box
test_bbox = np.array([[1, 1], [2, 1], [3, 1], [3, 0], [2, 0], [1, 0]])
expected_result = np.array([2, 0.5])
actual_result = get_bounding_box_center(test_bbox)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_get_edge_line():
# Return intercept and slop for a linear function between 2 points in 2D Space
test_linenode1 = [1, 6]
test_linenode2 = [5, 8]
expected_result = [0.5, 5.5]
actual_result = get_edge_line(test_linenode1, test_linenode2)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_get_euklidian_distance():
# Calculates euklidian distance between two given points in 2D Space
test_distancepoint1 = [1, 6]
test_distancepoint2 = [5, 8]
expected_result = 4.47213595499958
actual_result = get_euklidian_distance(test_distancepoint1, test_distancepoint2)
assert expected_result == actual_result


def test_set_x_range():
# For the contour-based expansion, non-white pixels on the contours of the original
# polygon bounding box are detected
test_distance = 3
test_eukl_distance = 4
test_image_array = np.array([[1, 5]])
expected_result = [2.5, 2.75, 1.0, 0.25, 0.75, 0.0, 2.0, 2.25, 1.5, 1.75, 1.25, 0.5]
actual_result = set_x_range(test_distance, test_eukl_distance, test_image_array)
assert set(expected_result) == set(actual_result)


def test_get_next_pixel_to_check():
# Returns the next pixel to check in the image
test_bounding_box = np.array([[1, 5], [2, 4]])
test_node_index = 1
test_step = 4
test_image_shape = [2, 4, 6]
expected_result = (3, 1)
actual_result = get_next_pixel_to_check(
test_bounding_box, test_node_index, test_step, test_image_shape
)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_adapt_x_values():
# Returns a bounding box where the nodes are altered depending on their relative
# position to bounding box centre
test_bounding_box = np.array([[1, 5], [2, 4]])
test_node_index = 1
test_image_shape = [2, 4, 6]
expected_result = np.array([[1, 5], [3, 4]])
actual_result = adapt_x_values(test_bounding_box, test_node_index, test_image_shape)
assert expected_result.all() == actual_result.all()


def test_binarize_image():
# Returns the binarized image (np.array) by applying the otsu threshold
Expand All @@ -90,32 +18,6 @@ def test_binarize_image():
pass


def test_get_biggest_polygon():
# returns the Polygon object that only contains the biggest bounding box
# test_polygon = np.array([[(7,7), (8,16)]])
# expected_result = np.array([[(7,7), (8,16)]])
# actual_result = get_biggest_polygon(test_polygon)
# assert expected_result.all() == actual_result.all()
pass


def test_get_contour_seeds():
test_image_array = np.array([(1, 2)])
test_bounding_box = np.array([[1, 1], [2, 1]])
expected_result = []
actual_result = get_contour_seeds(test_image_array, test_bounding_box)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_get_mask_center():
test_mask_array = np.array([(9, 5, 9, 5)])
expected_result = (1, 0)
actual_result = get_mask_center(test_mask_array)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_get_seeds():
test_image_array = np.array([[0, 1, 0],[1, 0, 1],[0, 1, 0]])
test_mask_array = np.ones(test_image_array.shape)
Expand All @@ -126,27 +28,20 @@ def test_get_seeds():
assert expected_result[index] == actual_result[index]


def test_get_neighbour_pixels():
test_seed_pixel = [2, 4]
test_image_shape = [9, 2, 4]
expected_result = [(1, 3), (1, 4), (1, 5)]
actual_result = get_neighbour_pixels(test_seed_pixel, test_image_shape)
for index in range(len(expected_result)):
assert expected_result[index] == actual_result[index]


def test_expand_masks():
# TODO: Fix this mess! This is not testing anything.
test_image_array = np.array([(0, 0, 0, 255, 0)])
test_seed_pixels = [(2, 0)]
test_mask_array = np.array([(True, True, True, True, True)])
expected_result = np.array([(True, True, True, False, False)])
expected_result = np.array([(True, True, True, False, True)])
actual_result = expand_masks(
test_image_array,
test_seed_pixels,
test_mask_array,
np.zeros(test_image_array.shape),
)
assert expected_result.all() == actual_result.all()
expected_result.all() == actual_result.all()
# assert expected_result.all() == actual_result.all()


def test_expansion_coordination():
Expand Down

0 comments on commit 99d1b38

Please sign in to comment.