alexandrebarachant/pyRiemann

View on GitHub
pyriemann/clustering.py

Summary

Maintainability
D
2 days
Test Coverage

File clustering.py has 697 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Clustering functions."""
import numpy as np
from joblib import Parallel, delayed
from scipy.stats import norm, chi2
import sklearn
Severity: Major
Found in pyriemann/clustering.py - About 1 day to fix

    Function _fit_single has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _fit_single(X, y=None, n_clusters=2, init="random", random_state=None,
    Severity: Major
    Found in pyriemann/clustering.py - About 1 hr to fix

      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, n_clusters=2, max_iter=100, metric="riemann",
      Severity: Major
      Found in pyriemann/clustering.py - About 1 hr to fix

        Function fit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def fit(self, X, y=None):
                """Fit (estimates) the clusters.
        
                Parameters
                ----------
        Severity: Minor
        Found in pyriemann/clustering.py - About 55 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

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

            def __init__(self, n_potatoes=1, p_threshold=0.01, z_threshold=3,
        Severity: Major
        Found in pyriemann/clustering.py - About 50 mins to fix

          Function _check_labels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _check_labels(self, X, y):
                  """Check validity of labels."""
                  if y is not None:
                      if len(y) != len(X):
                          raise ValueError("y must be the same length of X")
          Severity: Minor
          Found in pyriemann/clustering.py - About 45 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

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

              def __init__(self, metric="riemann", threshold=3, n_iter_max=100,
          Severity: Minor
          Found in pyriemann/clustering.py - About 35 mins to fix

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

            def _init_centroids(X, n_clusters, init, random_state, x_squared_norms):
            Severity: Minor
            Found in pyriemann/clustering.py - About 35 mins to fix

              Function fit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def fit(self, X, y=None):
                      """Fit the potato from SPD matrices.
              
                      Fit the potato from SPD matrices, with an iterative outlier
                      removal to obtain a reliable potato.
              Severity: Minor
              Found in pyriemann/clustering.py - About 35 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