Code Duplication    Length = 32-36 lines in 2 locations

pyclustering/nnet/sync.py 2 locations

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