Code Duplication    Length = 32-36 lines in 2 locations

pyclustering/nnet/sync.py 2 locations

@@ 414-449 (lines=36) @@
411
        """
412
        if (start_iteration is None):
413
            start_iteration = len(self._dynamic) - 1;
414
        
415
        if (stop_iteration is None):
416
            stop_iteration = start_iteration + 1;
417
        
418
        return (start_iteration, stop_iteration);
419
420
421
422
class sync_visualizer:
423
    """!
424
    @brief Visualizer of output dynamic of sync network (Sync).
425
    
426
    """
427
428
    @staticmethod
429
    def show_output_dynamic(sync_output_dynamic):
430
        """!
431
        @brief Shows output dynamic (output of each oscillator) during simulation.
432
        
433
        @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
434
        
435
        @see show_output_dynamics
436
        
437
        """
438
        
439
        draw_dynamics(sync_output_dynamic.time, sync_output_dynamic.output, x_title = "t", y_title = "phase", y_lim = [0, 2 * 3.14]);
440
    
441
    
442
    @staticmethod
443
    def show_output_dynamics(sync_output_dynamics):
444
        """!
445
        @brief Shows several output dynamics (output of each oscillator) during simulation.
446
        @details Each dynamic is presented on separate plot.
447
        
448
        @param[in] sync_output_dynamics (list): list of output dynamics 'sync_dynamic' of the Sync network.
449
        
450
        @see show_output_dynamic
451
        
452
        """
@@ 380-411 (lines=32) @@
377
        @details Local order parameter or so-called level of local or partial synchronization is calculated by following expression:
378
        
379
        \f[
380
        r_{c}=\left | \sum_{i=0}^{N} \frac{1}{N_{i}} \sum_{j=0}e^{ \theta_{j} - \theta_{i} } \right |;
381
        \f]
382
        
383
        where N - total amount of oscillators in the network and \f$N_{i}\f$ - amount of neighbors of oscillator with index \f$i\f$.
384
        
385
        @param[in] oscillatory_network (sync): Sync oscillatory network whose structure of connections is required for calculation.
386
        @param[in] start_iteration (uint): The first iteration that is used for calculation, if 'None' then the last iteration is used.
387
        @param[in] stop_iteration (uint): The last iteration that is used for calculation, if 'None' then 'start_iteration' + 1 is used.
388
        
389
        @return (list) List of levels of local (partial) synchronization (local order parameter evolution).
390
        
391
        """
392
393
        (start_iteration, stop_iteration) = self.__get_start_stop_iterations(start_iteration, stop_iteration);
394
        
395
        sequence_local_order = [];
396
        for index in range(start_iteration, stop_iteration):
397
            sequence_local_order.append(order_estimator.calculate_local_sync_order(self.output[index], oscillatory_network));
398
        
399
        return sequence_local_order;
400
401
402
    def __get_start_stop_iterations(self, start_iteration, stop_iteration):
403
        """!
404
        @brief Aplly rules for start_iteration and stop_iteration parameters.
405
406
        @param[in] start_iteration (uint): The first iteration that is used for calculation.
407
        @param[in] stop_iteration (uint): The last iteration that is used for calculation.
408
        
409
        @return (tuple) New the first iteration and the last.
410
        
411
        """
412
        if (start_iteration is None):
413
            start_iteration = len(self._dynamic) - 1;
414