refining ClustersFactoryTest

This commit is contained in:
frankknoll
2023-11-16 15:11:25 +01:00
parent 487ff3eff0
commit 457b2c6dd7

View File

@@ -24,6 +24,28 @@ class ClustersFactoryTest(unittest.TestCase):
[0] [0]
])) ]))
def test_createPreferenceMatrix2(self):
# Given
points = [(1, 0), (2, 0), (3, 0), (1, 1), (2, 2), (3, 3)]
lines = [Line.from_points([0, 0], [1, 0]), Line.from_points([0, 0], [1, 1])]
consensusThreshold = 0.001
# When
preferenceMatrix = ClustersFactory.createPreferenceMatrix(points, lines, consensusThreshold)
# Then
np.testing.assert_array_equal(
preferenceMatrix,
np.array(
[
[1, 0],
[1, 0],
[1, 0],
[0, 1],
[0, 1],
[0, 1]
]))
def test_createClusters(self): def test_createClusters(self):
# Given # Given
preferenceMatrix = np.array( preferenceMatrix = np.array(
@@ -42,3 +64,26 @@ class ClustersFactoryTest(unittest.TestCase):
[ [
[1, 0] [1, 0]
])) ]))
def test_createClusters2(self):
# Given
preferenceMatrix = np.array(
[
[1, 1],
[1, 0],
[1, 0],
[0, 1],
[0, 1]
])
# When
_, clusters = ClustersFactory.createClusters(preferenceMatrix)
# Then
np.testing.assert_array_equal(
clusters,
np.array(
[
[2, 1, 0],
[4, 3]
]))