alexandrebarachant/pyRiemann

View on GitHub
pyriemann/datasets/sampling.py

Summary

Maintainability
D
1 day
Test Coverage

File sampling.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from functools import partial
import warnings
import numpy as np
from scipy.stats import multivariate_normal
from sklearn.utils import check_random_state
Severity: Minor
Found in pyriemann/datasets/sampling.py - About 7 hrs to fix

    Function _slice_one_sample has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _slice_one_sample(ptarget, x0, w, rs):
        """Slice sampling for one sample
    
        Parameters
        ----------
    Severity: Minor
    Found in pyriemann/datasets/sampling.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _rejection_sampling_2D has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _rejection_sampling_2D(n_samples, sigma, random_state=None,
                               return_acceptance_rate=False):
        """Rejection sampling algorithm for the 2D case.
    
        Implementation of a rejection sampling algorithm. The implementation
    Severity: Minor
    Found in pyriemann/datasets/sampling.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _slice_sampling has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _slice_sampling(ptarget, n_samples, x0, n_burnin=20, thin=10,
    Severity: Major
    Found in pyriemann/datasets/sampling.py - About 50 mins to fix

      Function _sample_gaussian_spd_centered has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _sample_gaussian_spd_centered(n_matrices, n_dim, sigma, random_state=None,
      Severity: Minor
      Found in pyriemann/datasets/sampling.py - About 45 mins to fix

        Function sample_gaussian_spd has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def sample_gaussian_spd(n_matrices, mean, sigma, random_state=None,
        Severity: Minor
        Found in pyriemann/datasets/sampling.py - About 45 mins to fix

          Function _sample_parameter_r has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _sample_parameter_r(n_samples, n_dim, sigma,
          Severity: Minor
          Found in pyriemann/datasets/sampling.py - About 45 mins to fix

            Function generate_random_spd_matrix has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def generate_random_spd_matrix(n_dim, random_state=None, *, mat_mean=.0,
            Severity: Minor
            Found in pyriemann/datasets/sampling.py - About 35 mins to fix

              Function _slice_sampling has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def _slice_sampling(ptarget, n_samples, x0, n_burnin=20, thin=10,
                                  random_state=None, n_jobs=1):
                  """Slice sampling procedure.
              
                  Implementation of a slice sampling algorithm for sampling from any target
              Severity: Minor
              Found in pyriemann/datasets/sampling.py - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              There are no issues that match your filters.

              Category
              Status