KulikDM/pythresh

View on GitHub

Showing 21 of 39 total issues

File mixmod.py has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from itertools import combinations

import numpy as np
import scipy.optimize as opt
import scipy.stats as stats
Severity: Minor
Found in pythresh/thresholds/mixmod.py - About 4 hrs to fix

    File gamgmm.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import warnings
    
    import numpy as np
    from scipy.optimize import least_squares
    from scipy.stats import beta, dirichlet, multivariate_normal, wishart
    Severity: Minor
    Found in pythresh/thresholds/gamgmm.py - About 2 hrs to fix

      Function _compute_gamma_posterior has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _compute_gamma_posterior(self, decision):
      
              # Handle overflow of components versus samples.
              self.K = decision.shape[0] - \
                  1 if np.shape(decision)[0] < self.K else self.K
      Severity: Minor
      Found in pythresh/thresholds/gamgmm.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 eval has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def eval(self, decision):
              """Outlier/inlier evaluation process for decision scores.
      
              Parameters
              ----------
      Severity: Minor
      Found in pythresh/thresholds/comb.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 eval has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def eval(self, decision):
              """Outlier/inlier evaluation process for decision scores.
      
              Parameters
              ----------
      Severity: Minor
      Found in pythresh/thresholds/meta.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 eval has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def eval(self, decision):
              """Outlier/inlier evaluation process for decision scores.
      
              Parameters
              ----------
      Severity: Minor
      Found in pythresh/thresholds/mixmod.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Major
      Found in pythresh/thresholds/gamgmm.py - About 1 hr to fix

        Function _sample_withexactprobs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _sample_withexactprobs(self, means, mean_precs, covariances, dgf, delta, tau, w):
                """This function computes the joint probabilities and use them to get a sample from gamma's posterior."""
        
                K = np.shape(means)[0]
                mean_std = np.sqrt(1/mean_precs)
        Severity: Minor
        Found in pythresh/thresholds/gamgmm.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 fit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def fit(self, data):
                """Fit the free parameters of the mixture model with EM algorithm."""
        
                weights_opt = self.weights.copy()
                params_opt = []
        Severity: Minor
        Found in pythresh/thresholds/mixmod.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, verbose=False, device='cpu', latent_dims='auto',
        Severity: Major
        Found in pythresh/thresholds/vae.py - About 50 mins to fix

          Function _sample_withexactprobs has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _sample_withexactprobs(self, means, mean_precs, covariances, dgf, delta, tau, w):
          Severity: Major
          Found in pythresh/thresholds/gamgmm.py - About 50 mins to fix

            Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, model='sgd', degree='auto', gamma='auto',
            Severity: Major
            Found in pythresh/thresholds/ocsvm.py - About 50 mins to fix

              Function eval has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def eval(self, decision):
                      """Outlier detection and thresholding method confidence interval bounds.
              
                      Parameters
                      ----------
              Severity: Minor
              Found in pythresh/utils/conf.py - About 45 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, input_size, latent_size,
              Severity: Minor
              Found in pythresh/thresholds/vae.py - About 45 mins to fix

                Function eval has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def eval(self, X):
                        """Outlier detection and thresholding method ranking.
                
                        Parameters
                        ----------
                Severity: Minor
                Found in pythresh/utils/rank.py - About 45 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 _dtheta has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _dtheta(self, x, y, dx, dy, r2):
                Severity: Minor
                Found in pythresh/thresholds/wind.py - About 35 mins to fix

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

                      def __init__(self, thresh, alpha=0.05, split=0.25, n_test=100, random_state=1234):
                  Severity: Minor
                  Found in pythresh/utils/conf.py - About 35 mins to fix

                    Function _find_local_maxima_idx has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _find_local_maxima_idx(self, hist):
                            """Find the local maxima in histogram."""
                    
                            maximum_idxs = []
                            direction = 1
                    Severity: Minor
                    Found in pythresh/thresholds/hist.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

                    Function eval has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def eval(self, decision):
                            """Outlier/inlier evaluation process for decision scores.
                    
                            Parameters
                            ----------
                    Severity: Minor
                    Found in pythresh/thresholds/fgd.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

                    Function _rank_sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _rank_sort(self, sortings, weights):
                            """Sort weighted rankings."""
                    
                            # Get unique index values for ranking
                            unique_values = {value for ls in sortings for value in ls}
                    Severity: Minor
                    Found in pythresh/utils/rank.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