def test_intra_similarity_of_empty_cluster(self): """ Test that the intra-similarity of an empty cluster is 0. """ c = Cluster() self.assertEqual(0, c.get_intra_similarity())
def test_intra_similarity_of_cluster_with_single_vector(self): """ Test that the intra-similarity of a cluster with a single vector is equivalent to that vector's similarity with the cluster. """ v = Document("", ['a', 'b'], scheme=TF()) c = Cluster(v) self.assertEqual(c.similarity(v), c.get_intra_similarity())
def test_intra_similarity_of_cluster(self): """ Test that the intra-similarity of a cluster with several vectors is equivalent to the average similarity. """ v = [ Document("", ['a', 'b'], scheme=TF()), Document("", ['a', 'a'], scheme=TF()), ] c = Cluster(v) self.assertEqual((c.similarity(v[0]) + c.similarity(v[1])) / 2., c.get_intra_similarity())