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
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,
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, n_clusters=2, max_iter=100, metric="riemann",
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
----------
- 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, n_potatoes=1, p_threshold=0.01, z_threshold=3,
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")
- 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 __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, metric="riemann", threshold=3, n_iter_max=100,
Function _init_centroids
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _init_centroids(X, n_clusters, init, random_state, x_squared_norms):
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.
- 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"