Code Duplication    Length = 25-27 lines in 2 locations

pyclustering/cluster/birch.py 1 location

@@ 199-223 (lines=25) @@
196
            (cluster_distance, cluster_index) = self.__get_nearest_feature(self.__pointer_data[index_point], self.__features);
197
            (outlier_distance, _) = self.__get_nearest_feature(self.__pointer_data[index_point], self.__outlier_features);
198
            
199
            if (cluster_distance < outlier_distance):
200
                self.__clusters[cluster_index].append(index_point);
201
            else:
202
                self.__noise.append(index_point);
203
    
204
    
205
    def __insert_data(self):
206
        """!
207
        @brief Inserts input data to the tree.
208
        
209
        @remark If number of maximum number of entries is exceeded than diameter is increased and tree is rebuilt.
210
        
211
        """
212
        
213
        for index_point in range(0, len(self.__pointer_data)):
214
            point = self.__pointer_data[index_point];
215
            self.__tree.insert_cluster( [ point ] );
216
            
217
            if (self.__tree.amount_entries > self.__entry_size_limit):
218
                self.__tree = self.__rebuild_tree(index_point);
219
        
220
        #self.__tree.show_feature_destibution(self.__pointer_data);
221
    
222
    
223
    def __rebuild_tree(self, index_point):
224
        """!
225
        @brief Rebuilt tree in case of maxumum number of entries is exceeded.
226
        

pyclustering/container/cftree.py 1 location

@@ 570-596 (lines=27) @@
567
        farthest_node2 = None;
568
        farthest_distance = 0;
569
        
570
        for i in range(0, len(self.successors)):
571
            candidate1 = self.successors[i];
572
            
573
            for j in range(i + 1, len(self.successors)):
574
                candidate2 = self.successors[j];
575
                candidate_distance = candidate1.get_distance(candidate2, type_measurement);
576
                
577
                if (candidate_distance > farthest_distance):
578
                    farthest_distance = candidate_distance;
579
                    farthest_node1 = candidate1;
580
                    farthest_node2 = candidate2;        
581
        
582
                    return [farthest_node1, farthest_node2];
583
    
584
    
585
    def get_nearest_successors(self, type_measurement):
586
        """!
587
        @brief Find pair of nearest successors of the node in line with measurement type.
588
        
589
        @param[in] type_measurement (measurement_type): Measurement type that is used for obtaining nearest successors.
590
        
591
        @return (list) Pair of nearest successors represented by list.
592
        
593
        """
594
                
595
        nearest_node1 = None;
596
        nearest_node2 = None;
597
        nearest_distance = float("Inf");
598
        
599
        for i in range(0, len(self.successors)):