Code Duplication    Length = 32-36 lines in 2 locations

pyclustering/nnet/sync.py 2 locations

@@ 414-449 (lines=36) @@
411
        return (start_iteration, stop_iteration);
412
413
414
415
class sync_visualizer:
416
    """!
417
    @brief Visualizer of output dynamic of sync network (Sync).
418
    
419
    """
420
421
    @staticmethod
422
    def show_output_dynamic(sync_output_dynamic):
423
        """!
424
        @brief Shows output dynamic (output of each oscillator) during simulation.
425
        
426
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
427
        
428
        @see show_output_dynamics
429
        
430
        """
431
        
432
        draw_dynamics(sync_output_dynamic.time, sync_output_dynamic.output, x_title = "t", y_title = "phase", y_lim = [0, 2 * 3.14]);
433
    
434
    
435
    @staticmethod
436
    def show_output_dynamics(sync_output_dynamics):
437
        """!
438
        @brief Shows several output dynamics (output of each oscillator) during simulation.
439
        @details Each dynamic is presented on separate plot.
440
        
441
        @param[in] sync_output_dynamics (list): list of output dynamics 'sync_dynamic' of the Sync network.
442
        
443
        @see show_output_dynamic
444
        
445
        """
446
        
447
        draw_dynamics_set(sync_output_dynamics, "t", "phase", None, [0, 2 * 3.14], False, False);
448
    
449
    
450
    @staticmethod
451
    def show_correlation_matrix(sync_output_dynamic, iteration = None):
452
        """!
@@ 380-411 (lines=32) @@
377
        
378
        """
379
        
380
        exp_amount = 0.0;
381
        num_neigh = 0.0;
382
        
383
        for i in range(0, len(oscillatory_network), 1):
384
            for j in range(0, len(oscillatory_network), 1):
385
                if (oscillatory_network.has_connection(i, j) == True):
386
                    exp_amount += math.exp(-abs(oscillator_phases[j] - oscillator_phases[i]));
387
                    num_neigh += 1.0;
388
        
389
        if (num_neigh == 0):
390
            num_neigh = 1.0;
391
        
392
        return exp_amount / num_neigh;
393
394
395
    def __get_start_stop_iterations(self, start_iteration, stop_iteration):
396
        """!
397
        @brief Aplly rules for start_iteration and stop_iteration parameters.
398
399
        @param[in] start_iteration (uint): The first iteration that is used for calculation.
400
        @param[in] stop_iteration (uint): The last iteration that is used for calculation.
401
        
402
        @return (tuple) New the first iteration and the last.
403
        
404
        """
405
        if (start_iteration is None):
406
            start_iteration = len(self._dynamic) - 1;
407
        
408
        if (stop_iteration is None):
409
            stop_iteration = start_iteration + 1;
410
        
411
        return (start_iteration, stop_iteration);
412
413
414