Code Duplication    Length = 25-27 lines in 2 locations

pyclustering/cluster/birch.py 1 location

@@ 199-223 (lines=25) @@
196
        
197
        """
198
        
199
        for index_point in range(0, len(self.__pointer_data)):
200
            point = self.__pointer_data[index_point];
201
            self.__tree.insert_cluster( [ point ] );
202
            
203
            if (self.__tree.amount_entries > self.__entry_size_limit):
204
                self.__tree = self.__rebuild_tree(index_point);
205
        
206
        #self.__tree.show_feature_destibution(self.__pointer_data);
207
    
208
    
209
    def __rebuild_tree(self, index_point):
210
        """!
211
        @brief Rebuilt tree in case of maxumum number of entries is exceeded.
212
        
213
        @param[in] index_point (uint): Index of point that is used as end point of re-building.
214
        
215
        @return (cftree) Rebuilt tree with encoded points till specified point from input data space.
216
        
217
        """
218
        
219
        rebuild_result = False;
220
        increased_diameter = self.__tree.threshold * self.__diameter_multiplier;
221
        
222
        tree = None;
223
        
224
        while(rebuild_result is False):
225
            # increase diameter and rebuild tree
226
            if (increased_diameter == 0.0):

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)):