altugkarakurt/ModeTonicEstimation

View on GitHub

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
Severity: Minor
Found in morty/pitchdistribution.py - About 4 hrs to fix

    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.
    Severity: Minor
    Found in morty/pitchdistribution.py - About 3 hrs to fix

      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
      Severity: Minor
      Found in morty/classifiers/knnclassifier.py - About 2 hrs to fix

        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,
        Severity: Minor
        Found in morty/classifiers/knn.py - About 1 hr 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 _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
        Severity: Minor
        Found in morty/classifiers/knn.py - About 55 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 _estimate has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _estimate(self, test_feature, mode=None, est_tonic=True,
        Severity: Major
        Found in morty/classifiers/knnclassifier.py - About 50 mins to fix

          Function estimate_tonic has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def estimate_tonic(self, test_input, mode, min_peak_ratio=0.1,
          Severity: Minor
          Found in morty/classifiers/knnclassifier.py - About 45 mins to fix

            Function identify_tonic has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def identify_tonic(self, test_input, mode, min_peak_ratio=0.1,
            Severity: Minor
            Found in morty/classifiers/knnclassifier.py - About 45 mins to fix

              Function estimate_mode has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def estimate_mode(self, feature_in, tonic=None, distance_method='bhat',
              Severity: Minor
              Found in morty/classifiers/knnclassifier.py - About 35 mins to fix

                Function train has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def train(self, pitches, tonics, modes, sources=None, model_type='multi'):
                Severity: Minor
                Found in morty/classifiers/knnclassifier.py - About 35 mins to fix

                  Function recognize_mode has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def recognize_mode(self, feature_in, tonic=None, distance_method='bhat',
                  Severity: Minor
                  Found in morty/classifiers/knnclassifier.py - About 35 mins to fix

                    Function estimate_joint has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def estimate_joint(self, test_input, min_peak_ratio=0.1,
                    Severity: Minor
                    Found in morty/classifiers/knnclassifier.py - About 35 mins to fix

                      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)
                      Severity: Minor
                      Found in morty/classifiers/inputparser.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 np.sqrt(
                      Severity: Major
                      Found in morty/classifiers/knn.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return 1.0 - np.sum(np.minimum(vals_1, vals_2)) / np.size(vals_1)
                        Severity: Major
                        Found in morty/classifiers/knn.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return 1.0 - np.correlate(vals_1, vals_2)
                          Severity: Major
                          Found in morty/classifiers/knn.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return 0
                            Severity: Major
                            Found in morty/classifiers/knn.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return (np.sum(vals_1 * np.log(vals_1 / vals_2)) +
                              Severity: Major
                              Found in morty/classifiers/knn.py - About 30 mins to fix

                                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:
                                Severity: Minor
                                Found in morty/extras/foldgenerator.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