alexandrebarachant/pyRiemann

View on GitHub
pyriemann/utils/distance.py

Summary

Maintainability
C
1 day
Test Coverage

File distance.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Distances between SPD/HPD matrices."""

import numpy as np
from scipy.linalg import eigvalsh, solve
from sklearn.metrics import euclidean_distances
Severity: Major
Found in pyriemann/utils/distance.py - About 1 day to fix

    Function pairwise_distance has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def pairwise_distance(X, Y=None, metric="riemann", squared=False):
        """Pairwise distance matrix.
    
        Compute the matrix of distances between pairs of elements of X and Y.
    
    
    Severity: Minor
    Found in pyriemann/utils/distance.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 _recursive has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _recursive(fun, A, B, *args, **kwargs):
    Severity: Minor
    Found in pyriemann/utils/distance.py - About 35 mins to fix

      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 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

        There are no issues that match your filters.

        Category
        Status