def test_cluster_perfect_center(self):
     centroids = np.zeros((self.cluster_count,dna.DNA.kmer_hash_count))
     centroids[0,:] = multinomial.fit_nonzero_parameters([self.contigs[0],self.contigs[1]])
     centroids[1,:] = multinomial.fit_nonzero_parameters([self.contigs[2],self.contigs[3]])
     correct_clusters = kmeans._expectation(self.contigs,multinomial.log_probabilities,centroids)        
     
    	self.params["centroids"] = centroids
     (clusters, clust_prob,new_centroids) = kmeans._clustering(self.cluster_count, self.max_iter, self.run, self.epsilon, self.verbose, multinomial.log_probabilities, multinomial.fit_nonzero_parameters, **self.params)
     assert_equal(kmeans._evaluate_clustering(multinomial.log_probabilities, correct_clusters, centroids),clust_prob)
 def test_generate_kplusplus_centroids(self):
     centroids = kmeans._generate_kplusplus(self.contigs,multinomial.log_probabilities, multinomial.fit_nonzero_parameters,self.cluster_count,dna.DNA.kmer_hash_count,self.rs)
     assert_equal(len(centroids), self.cluster_count)
     assert_equal(len(centroids[0]),dna.DNA.kmer_hash_count )
     assert_equal(np.sum(centroids,axis=1).all(),1)
     
     correct_centroids = np.zeros((self.cluster_count,dna.DNA.kmer_hash_count))
     correct_centroids[0,:] = multinomial.fit_nonzero_parameters([self.contigs[0], self.contigs[1]])
     correct_centroids[1,:] = multinomial.fit_nonzero_parameters([self.contigs[2], self.contigs[3]])
     correct_clusters = kmeans._expectation(self.contigs,multinomial.log_probabilities,correct_centroids)
     correct_clust_prob = kmeans._evaluate_clustering(multinomial.log_probabilities, correct_clusters,correct_centroids)
    	self.params["centroids"] = correct_centroids
     (clusters, clust_prob,new_centroids) = kmeans._clustering(self.cluster_count, self.max_iter, self.run, self.epsilon, self.verbose, multinomial.log_probabilities, multinomial.fit_nonzero_parameters, **self.params)
     print clust_prob
     assert_almost_equal(0, min(np.abs(clust_prob - np.array([-1659.9510320847476, -1652.322663414292, -1658.28785337, -1665.52431153]))))