Code Duplication    Length = 32-36 lines in 2 locations

pyclustering/nnet/sync.py 2 locations

@@ 414-449 (lines=36) @@
411
        _ = plt.figure();
412
        phase_matrix = sync_output_dynamic.allocate_phase_matrix(grid_width, grid_height, iteration);
413
        
414
        plt.imshow(phase_matrix, cmap = plt.get_cmap('jet'), interpolation='kaiser', vmin = 0.0, vmax = 2.0 * math.pi); 
415
        plt.show();
416
417
418
    @staticmethod
419
    def show_order_parameter(sync_output_dynamic, start_iteration = None, stop_iteration = None):
420
        """!
421
        @brief Shows evolution of order parameter (level of global synchronization in the network).
422
        
423
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network whose evolution of global synchronization should be visualized.
424
        @param[in] start_iteration (uint): The first iteration that is used for calculation, if 'None' then the first is used
425
        @param[in] stop_iteration (uint): The last iteration that is used for calculation, if 'None' then the last is used.
426
        
427
        """
428
        
429
        if (start_iteration is None):
430
            start_iteration = 0;
431
        
432
        if (stop_iteration is None):
433
            stop_iteration = len(sync_output_dynamic);
434
        
435
        order_parameter = sync_output_dynamic.calculate_order_parameter(start_iteration, stop_iteration);
436
        axis = plt.subplot(111);
437
        plt.plot(sync_output_dynamic.time[start_iteration:stop_iteration], order_parameter, 'b-', linewidth = 2.0);
438
        set_ax_param(axis, "t", "R (order parameter)", None, [0.0, 1.05]);
439
        
440
        plt.show();
441
442
443
    @staticmethod
444
    def animate_output_dynamic(sync_output_dynamic, animation_velocity = 75, save_movie = None):
445
        """!
446
        @brief Shows animation of output dynamic (output of each oscillator) during simulation on a circle from [0; 2pi].
447
        
448
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
449
        @param[in] animation_velocity (uint): Interval between frames in milliseconds.
450
        @param[in] save_movie (string): If it is specified then animation will be stored to file that is specified in this parameter.
451
        
452
        """
@@ 380-411 (lines=32) @@
377
    @staticmethod
378
    def show_correlation_matrix(sync_output_dynamic, iteration = None):
379
        """!
380
        @brief Shows correlation matrix between oscillators at the specified iteration.
381
        
382
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
383
        @param[in] iteration (uint): Number of interation of simulation for which correlation matrix should be allocated.
384
                                      If iternation number is not specified, the last step of simulation is used for the matrix allocation.
385
        
386
        """
387
        
388
        _ = plt.figure();
389
        correlation_matrix = sync_output_dynamic.allocate_correlation_matrix(iteration);
390
        
391
        plt.imshow(correlation_matrix, cmap = plt.get_cmap('cool'), interpolation='kaiser', vmin = 0.0, vmax = 1.0); 
392
        plt.show();
393
394
395
    @staticmethod
396
    def show_phase_matrix(sync_output_dynamic, grid_width = None, grid_height = None, iteration = None):
397
        """!
398
        @brief Shows 2D matrix of phase values of oscillators at the specified iteration.
399
        @details User should ensure correct matrix sizes in line with following expression grid_width x grid_height that should be equal to 
400
                  amount of oscillators otherwise exception is thrown. If grid_width or grid_height are not specified than phase matrix size 
401
                  will by calculated automatically by square root.
402
        
403
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network whose phase matrix should be shown.
404
        @param[in] grid_width (uint): Width of the phase matrix.
405
        @param[in] grid_height (uint): Height of the phase matrix.
406
        @param[in] iteration (uint): Number of iteration of simulation for which correlation matrix should be allocated.
407
                    If iternation number is not specified, the last step of simulation is used for the matrix allocation.
408
        
409
        """
410
        
411
        _ = plt.figure();
412
        phase_matrix = sync_output_dynamic.allocate_phase_matrix(grid_width, grid_height, iteration);
413
        
414
        plt.imshow(phase_matrix, cmap = plt.get_cmap('jet'), interpolation='kaiser', vmin = 0.0, vmax = 2.0 * math.pi);