pyriemann/utils/distance.py
File distance.py
has 549 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"""Distances between SPD/HPD matrices."""
import numpy as np
from scipy.linalg import eigvalsh, solve
from sklearn.metrics import euclidean_distances
Function pairwise_distance
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
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.
- Read upRead up
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
Open
def _recursive(fun, A, B, *args, **kwargs):
Avoid too many return
statements within this function. Open
Open
return dist
Function distance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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.
- Read upRead up
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"