alexandrebarachant/pyRiemann

View on GitHub

Showing 138 of 185 total issues

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

    def _check_data_dim(self, X):
        """Check data shape and return the size of SPD matrix."""
        shape_X = X.shape
        if len(X.shape) == 2:
            n_channels = (np.sqrt(1 + 8 * shape_X[1]) - 1) / 2
Severity: Minor
Found in pyriemann/tangentspace.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

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

    def partial_fit(self, X, y=None, alpha=0.1):
        """Partially fit the potato from covariance matrices.

        This partial fit can be used to update dynamic or semi-dymanic online
        potatoes with clean EEG.
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

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

def median_riemann(X, *, tol=10e-6, maxiter=50, init=None, weights=None,
                   step_size=1):
    r"""Affine-invariant Riemannian geometric median of SPD/HPD matrices.

    The affine-invariant Riemannian geometric median minimizes the sum of
Severity: Minor
Found in pyriemann/utils/median.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

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

def online_detect(t):
    global time, sig, labels, covs_t, covs_z, covs_p

    # Online artifact detection
    rp_label = rp.predict(rp_covs[np.newaxis, t])[0]
Severity: Minor
Found in examples/artifacts/plot_detect_riemannian_potato_field_EEG.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

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

def make_matrices(n_matrices, n_dim, kind, rs=None, return_params=False,
                  evals_low=0.5, evals_high=2.0, eigvecs_same=False):
    """Generate a set of matrices, with specific properties.

    Parameters
Severity: Minor
Found in pyriemann/datasets/simulated.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

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

    def inverse_transform(self, X, supp=None):
        """Transform source space to channel space.

        Transform source space to channel space, applying backward spatial
        filters, with the possibility to suppress some sources, like in BSS
Severity: Minor
Found in pyriemann/spatialfilters.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

Avoid too many return statements within this function.
Open

    return dist
Severity: Major
Found in pyriemann/utils/distance.py - About 30 mins to fix

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

    def mean_logdet(X=None, tol=10e-5, maxiter=50, init=None, sample_weight=None,
                    covmats=None):
        r"""Mean of SPD/HPD matrices according to the log-det metric.
    
        Log-det mean is obtained by an iterative procedure where the update is:
    Severity: Minor
    Found in pyriemann/utils/mean.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

    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

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

    def freq_selection_class_dis(raw, freq_band=(5., 35.), sub_band_width=4,
                                 sub_band_step=2, alpha=0.4,
                                 tmin=0.5, tmax=2.5,
                                 picks=None, event_id=None,
                                 cv=None,
    Severity: Minor
    Found in examples/motor-imagery/helpers/frequencybandselection_helpers.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

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

    def _check_dimensions(X, Y=None, n_components=None, n_neighbors=None):
        n_matrices, n_channels, n_channels = X.shape
    
        if Y is not None and Y.shape[1:] != (n_channels, n_channels):
            msg = f"Dimension of matrices in data to be transformed must match " \
    Severity: Minor
    Found in pyriemann/embedding.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

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

    def distance(A, B, metric="riemann", squared=False):
        """Distance between matrices according to a metric.
    
        Compute the distance between two matrices A and B according to a metric
        [1]_, or between a set of matrices A and another matrix B.
    Severity: Minor
    Found in pyriemann/utils/distance.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

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

    def mean_wasserstein(X=None, tol=10e-4, maxiter=50, init=None,
                         sample_weight=None, covmats=None):
        r"""Mean of SPD/HPD matrices according to the Wasserstein metric.
    
        Wasserstein mean is obtained by an iterative procedure where the update is
    Severity: Minor
    Found in pyriemann/utils/mean.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

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

    def normalize(X, norm):
        """Normalize a set of square matrices, using corr, trace or determinant.
    
        Parameters
        ----------
    Severity: Minor
    Found in pyriemann/utils/covariance.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

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

    def _matrix_operator(C, operator):
        """Matrix function."""
        if not isinstance(C, np.ndarray) or C.ndim < 2:
            raise ValueError("Input must be at least a 2D ndarray")
        if C.dtype.char in typecodes['AllFloat'] and (
    Severity: Minor
    Found in pyriemann/utils/base.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

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

        def transform(self, X):
            """Apply spatial filters.
    
            Parameters
            ----------
    Severity: Minor
    Found in pyriemann/spatialfilters.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

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

    def check_weights(weights, n_weights, *, check_positivity=False):
        """Check weights.
    
        If input is None, output weights are equal.
        Strict positivity of weights can be checked.
    Severity: Minor
    Found in pyriemann/utils/utils.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

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

    def plot_embedding(X,
                       y=None,
                       *,
                       metric="riemann",
                       title="Embedding of covariances",
    Severity: Minor
    Found in pyriemann/utils/viz.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

    Severity
    Category
    Status
    Source
    Language