def test_to_dic(self): clustering = Clustering([ Cluster(16, [16]), Cluster(9, [9, 10, 11, 12, 13, 14, 15]), Cluster(0, [0, 1, 2, 3]), Cluster(4, [4, 5, 6, 7, 8]) ]) self.assertDictEqual( clustering.to_dic(), { 'clusters': [{ 'prototype': 9, 'elements': '9:15', 'id': 'cluster_1' }, { 'prototype': 4, 'elements': '4:8', 'id': 'cluster_3' }, { 'prototype': 0, 'elements': '0:3', 'id': 'cluster_2' }, { 'prototype': 16, 'elements': '16', 'id': 'cluster_0' }], 'total_number_of_elements': 17, 'number_of_clusters': 4 })
def test_to_dic(self): clustering =Clustering([Cluster(16,[16]), Cluster(9,[9,10,11,12,13,14,15]), Cluster(0,[0,1,2,3]), Cluster(4,[4,5,6,7,8])]) self.assertDictEqual(clustering.to_dic(), {'clusters': [{'prototype': 9, 'elements': '9:15', 'id': 'cluster_1'}, {'prototype': 4, 'elements': '4:8', 'id': 'cluster_3'}, {'prototype': 0, 'elements': '0:3', 'id': 'cluster_2'}, {'prototype': 16, 'elements': '16', 'id': 'cluster_0'}], 'total_number_of_elements': 17, 'number_of_clusters': 4})