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