DavidWalz/diversipy

View on GitHub

Showing 38 of 62 total issues

Function sample_from_strata has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring.
Open

def sample_from_strata(
    strata, bates_param=1, latin="none", matching_init="approx", full_output=False
):
    """Stratified sampling with given strata.

Severity: Minor
Found in diversipy/cube.py - About 2 days 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

File cube.py has 835 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Functions for (super-uniform) sampling from the unit hypercube.
"""
import random
import itertools
Severity: Major
Found in diversipy/cube.py - About 2 days to fix

    File indicator.py has 585 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This module contains several functions to measure diversity and a few
    related concepts. The diversity indicators all have different advantages and
    disadvantages. An overview is given in [Wessing2015]_.
    
    
    Severity: Major
    Found in diversipy/indicator.py - About 1 day to fix

      File subset.py has 461 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      This module contains algorithms for the task of subset selection: suppose
      you have a set of points in :math:`\\mathbb{R}^n` and want to select a sample
      of them distributed as uniform as possible. This problem is related to
      clustering, with the difference that when using clustering, you usually want
      Severity: Minor
      Found in diversipy/subset.py - About 7 hrs to fix

        Function sample_maximin has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

        def sample_maximin(
            num_points,
            dimension,
            num_steps=None,
            initial_points=None,
        Severity: Minor
        Found in diversipy/cube.py - About 5 hrs 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 wmh_index has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        def wmh_index(sep_dist, dist_p, num_points, dim, approx=None, full_output=False):
            """Quality index of Wahl, Mercadier, and Helbert.
        
            In [Wahl2017]_, the idea to use the probability to obtain a sample
            with a separation distance less or equal to `sep_dist` was presented.
        Severity: Minor
        Found in diversipy/indicator.py - About 3 hrs 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 sample_k_means has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def sample_k_means(
            num_points,
            dimension,
            num_steps=None,
            initial_points=None,
        Severity: Minor
        Found in diversipy/cube.py - About 3 hrs 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 weitzman_diversity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def weitzman_diversity(points, dist_args={}):
            """Calculate the Weitzman diversity for a set of points.
        
            This diversity indicator was introduced in [Weitzman1992]_. It is to be
            maximized.
        Severity: Minor
        Found in diversipy/indicator.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 stratify_generalized has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def stratify_generalized(
            num_strata, dimension, cuboid=None, detect_special_case=True, avoid_odd_numbers=True
        ):
            """Generalized stratification of the unit hypercube.
        
        
        Severity: Minor
        Found in diversipy/cube.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 select_greedy_energy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def select_greedy_energy(
            points,
            num_selected_points,
            existing_points=None,
            exponent=None,
        Severity: Minor
        Found in diversipy/subset.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 improved_latin_design has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def improved_latin_design(
            num_points,
            dimension,
            num_candidates=100,
            target_value=None,
        Severity: Minor
        Found in diversipy/cube.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 average_inverse_dist has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def average_inverse_dist(points, exponent=None, max_dist=1.0, dist_args={}):
            """Calculate the average inverse distance.
        
            For each pair of points, the value ``(max_dist / dist) ** exponent`` is
            computed. The average of all these values is the indicator value, which
        Severity: Minor
        Found in diversipy/indicator.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 obtain_representative_index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def obtain_representative_index(
                self, selection_target="centroid_of_hypercube", tournament_size=0, dist_args={},
            ):
                """Return the index to a point representing this cluster.
        
        
        Severity: Minor
        Found in diversipy/subset.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 unanchored_L2_discrepancy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def unanchored_L2_discrepancy(points):
            """Calculate unanchored L2 discrepancy.
        
            Discrepancy is to be minimized. Note that the square root is already
            taken. Coordinates of points must be >=0 and <=1. Run time is quadratic.
        Severity: Minor
        Found in diversipy/indicator.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def _init(n_dim):
            """Initialize the Sobol matrix"""
            poly = POLY[:, 0]
            V = np.zeros((DIM_MAX, LOG_MAX), dtype=int)
            V[:, :8] = POLY[:, 1:]
        Severity: Minor
        Found in diversipy/sobol.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 covering_radius_upper_bound has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def covering_radius_upper_bound(points, strata, dist_args):
            """Upper bound for the covering radius.
        
            The idea for this measure was presented in [Wessing2018]_.
        
        
        Severity: Minor
        Found in diversipy/indicator.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 sample has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def sample(n_points, lower, upper, A1=None, b1=None, A2=None, b2=None, thin=1):
        Severity: Major
        Found in diversipy/polytope.py - About 1 hr to fix

          Function sample_maximin has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def sample_maximin(
          Severity: Major
          Found in diversipy/cube.py - About 1 hr to fix

            Function sample has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def sample(n_points, lower, upper, A1=None, b1=None, A2=None, b2=None, thin=1):
                """Sample a number of points from a convex polytope A1 x <= b1 using the Hit & Run
                algorithm.
            
                Lower and upper bounds need to be provided to ensure that the polytope is bounded.
            Severity: Minor
            Found in diversipy/polytope.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 strata_from_points has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def strata_from_points(points, cuboid=None):
                """Partitions the cuboid so that each point has its own hyperbox.
            
                This partitioning is stochastic (ties are broken randomly). The obtained
                strata will have different volumes. This function can be used to
            Severity: Minor
            Found in diversipy/cube.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

            Severity
            Category
            Status
            Source
            Language