Commit f47f09ed authored by Josef Brandt's avatar Josef Brandt

Removed unused code

parent ee19bc2c
......@@ -114,63 +114,3 @@ class KennardStone(object):
index2 = np.where(self.data == candidates[j])[0][0]
assert index1 != index2
return sorted([index1, index2])
# def _get_point_furthest_from_other_points(self, refPoints: np.ndarray, otherPoints: np.ndarray) -> int:
# assert refPoints.shape[1] == 2
# assert otherPoints.shape[1] == 2
# dist_mat = spatial.distance_matrix(refPoints, otherPoints)
# i, index = np.unravel_index(dist_mat.argmax(), dist_mat.shape)
# return index
class BoundingAreaHierarchy(object):
def __init__(self, points: np.ndarray):
super(BoundingAreaHierarchy, self).__init__()
self.points: np.ndarray = points
self.tree: BAHNode = BAHNode(points)
self._populate_tree()
# def _populate_tree(self) -> None:
#
# class BAHNode(object):
# def __init__(self, parent, startxy: tuple, width: float, height: float, points: np.ndarray) -> None:
# super(BAHNode, self).__init__()
# self.maxPointsPerNode: int = 10
# self.parent: BAHNode = parent
# self.children: list = [] # if empty, we reached the lowest node level
# self.points: np.ndarray = np.array([]) # if empty, we are not at the lowest level and have to check children
# self.x0: float = startxy[0]
# self.y0: float = startxy[1]
# self.width: float = width
# self.height: float = height
# self.x1: float = self.x0 + width
# self.y1: float = self.y0 + height
# self._create_child_nodes(points)
#
# def _create_child_nodes(self, points:np.ndarray):
# if points.shape[0] > 0: # avoid testing for children in case of a testrun (empty array is provided as points)
# pointsInNode: np.ndarray = self._get_points_in_area(points)
# if pointsInNode.shape[0] > self.maxPointsPerNode:
# childWidth: float = self.width/2
# childHeight:float = self.height/2
#
# self.children.append(BAHNode(self, (self.x0, self.y1),
# childWidth, childHeight, pointsInNode))
#
# self.children.append(BAHNode(self, (self.x0 + childWidth, self.y1),
# childWidth, childHeight, pointsInNode))
#
# self.children.append(BAHNode(self, (self.x0, self.y1 + childHeight),
# childWidth, childHeight, pointsInNode))
#
# self.children.append(BAHNode(self, (self.x0 + childWidth, self.y1 + childHeight),
# childWidth, childHeight, pointsInNode))
#
#
# def _get_points_in_area(self, points:np.ndarray) -> np.ndarray:
# assert points.shape[1] == 2
# cond1: np.ndarray = np.logical_and(points[:, 0] >= self.x0, points[:, 0] < self.x1)
# cond2: np.ndarray = np.logical_and(points[:, 1] >= self.y0, points[:, 1] < self.y1)
# return points[np.logical_and(cond1, cond2)]
......@@ -99,23 +99,6 @@ class TestKennardStone(unittest.TestCase):
startIndices = self.kennardStone._get_start_indices()
self.assertEqual(startIndices, [4, len(points) - 1])
# def test_get_point_furthest_from_other_points(self):
# otherPoints: list = [[0, 0], [10, 0], [0, 10], [10, 10]]
# refPoints: list = [[2, 2]]
# indexOfFurthestPoint = self.kennardStone._get_point_furthest_from_other_points(np.array(refPoints),
# np.array(otherPoints))
# self.assertEqual(indexOfFurthestPoint, 3)
#
# refPoints: list = [[9, 9]]
# indexOfFurthestPoint = self.kennardStone._get_point_furthest_from_other_points(np.array(refPoints),
# np.array(otherPoints))
# self.assertEqual(indexOfFurthestPoint, 0)
#
# refPoints: list = [[2, 2], [3, 3], [-1, -5]]
# indexOfFurthestPoint = self.kennardStone._get_point_furthest_from_other_points(np.array(refPoints),
# np.array(otherPoints))
# self.assertEqual(indexOfFurthestPoint, 3)
class TestChemometricSubsampling(unittest.TestCase):
def setUp(self) -> None:
......@@ -146,43 +129,4 @@ class TestChemometricSubsampling(unittest.TestCase):
# plt.scatter(princComp[:, 0], princComp[:, 1])
# plt.title(dset.name)
# plt.show()
#
# class TestBAH(unittest.TestCase):
# # def setUp(self) -> None:
# # self.bah = cmeth.BoundingAreaHierarchy()
# #
# def test_get_points_in_area(self):
# points: np.ndarray = np.array([[0, 0], [0, 10], [10, 0], [10, 10]])
# topLeftXY = (0, 0)
# width, height = 5, 5
# bahNode: cmeth.BAHNode = cmeth.BAHNode(None, topLeftXY, width, height, np.array([]))
# ponitsInNode: np.ndarray = bahNode._get_points_in_area(points)
# self.assertEqual(ponitsInNode.shape[0], 1)
# self.assertTrue([0, 0] in ponitsInNode)
#
# width, height = 10, 10
# bahNode = cmeth.BAHNode(None, topLeftXY, width, height, np.array([]))
# ponitsInNode: np.ndarray = bahNode._get_points_in_area(points)
# self.assertEqual(ponitsInNode.shape[0], 1)
# self.assertTrue([0, 0] in ponitsInNode)
#
# width, height = 10.1, 10.1
# bahNode = cmeth.BAHNode(None, topLeftXY, width, height, np.array([]))
# ponitsInNode: np.ndarray = bahNode._get_points_in_area(points)
# self.assertEqual(ponitsInNode.shape[0], 4)
# for point in points:
# self.assertTrue(point in ponitsInNode)
#
# topLeftXY = (-5, -5)
# bahNode = cmeth.BAHNode(None, topLeftXY, width, height, np.array([]))
# ponitsInNode: np.ndarray = bahNode._get_points_in_area(points)
# self.assertEqual(ponitsInNode.shape[0], 1)
# self.assertTrue([0, 0] in ponitsInNode)
#
# width, height = 10, 20
# bahNode = cmeth.BAHNode(None, topLeftXY, width, height, np.array([]))
# ponitsInNode: np.ndarray = bahNode._get_points_in_area(points)
# self.assertEqual(ponitsInNode.shape[0], 2)
# for point in points[:2]:
# self.assertTrue(point in ponitsInNode)
\ No newline at end of file
#
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment