Showing 19 of 34 total issues
File pitchdistribution.py
has 363 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from __future__ import division
import essentia
import essentia.standard as std
import numpy as np
PitchDistribution
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class PitchDistribution(object):
def __init__(self, pd_bins, pd_vals, kernel_width=7.5, ref_freq=440.0):
"""-------------------------------------------------------------------
The main data structure that wraps all the relevant information about a
pitch distribution.
File knnclassifier.py
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import numpy as np
import pickle
import json
import copy
Function generate_distance_matrix
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def generate_distance_matrix(cls, distrib, peak_idx, training_distribs,
distance_method='bhat'):
"""--------------------------------------------------------------------
Iteratively calculates the distance of the input distribution from each
(mode candidate, tonic candidate) pair. This is a generic function,
- 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 _compute_measure
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _compute_measure(vals_1, vals_2, method='bhat'):
"""--------------------------------------------------------------------
Computes the distance or dissimilairty between two 1-D lists of
values. This function is called with pitch distribution values,
while generating matrices. The function is symmetric, the two input
- 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 _estimate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _estimate(self, test_feature, mode=None, est_tonic=True,
Function estimate_tonic
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def estimate_tonic(self, test_input, mode, min_peak_ratio=0.1,
Function identify_tonic
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def identify_tonic(self, test_input, mode, min_peak_ratio=0.1,
Function estimate_mode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def estimate_mode(self, feature_in, tonic=None, distance_method='bhat',
Function train
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def train(self, pitches, tonics, modes, sources=None, model_type='multi'):
Function recognize_mode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def recognize_mode(self, feature_in, tonic=None, distance_method='bhat',
Function estimate_joint
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def estimate_joint(self, test_input, min_peak_ratio=0.1,
Function _parse_mode_estimate_input
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _parse_mode_estimate_input(self, feature_in, tonic=None):
if isinstance(feature_in, PitchDistribution):
feature = copy.deepcopy(feature_in)
if tonic is not None: # tonic given
feature.hz_to_cent(tonic)
- 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
Avoid too many return
statements within this function. Open
return np.sqrt(
Avoid too many return
statements within this function. Open
return 1.0 - np.sum(np.minimum(vals_1, vals_2)) / np.size(vals_1)
Avoid too many return
statements within this function. Open
return 1.0 - np.correlate(vals_1, vals_2)
Avoid too many return
statements within this function. Open
return 0
Avoid too many return
statements within this function. Open
return (np.sum(vals_1 * np.log(vals_1 / vals_2)) +
Function _parse_mbid_mode_tonic
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _parse_mbid_mode_tonic(annotations, file_names, base_folders):
file_modes = [os.path.basename(b) for b in base_folders]
mbids = [os.path.splitext(f)[0] for f in file_names]
tonics = []
for m in mbids:
- 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"