DavidWalz/diversipy

View on GitHub

Showing 62 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if np.isinf(bates_param):
                          points[strat_idx][dim_index] = (low + high) * 0.5
                      elif bates_param == 1:
                          points[strat_idx][dim_index] = rand_uni(low, high)
                      else:
      Severity: Major
      Found in diversipy/cube.py and 1 other location - About 1 day to fix
      diversipy/cube.py on lines 613..619

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if np.isinf(bates_param):
                          points[j][dim_index] = (low + high) * 0.5
                      elif bates_param == 1:
                          points[j][dim_index] = rand_uni(low, high)
                      else:
      Severity: Major
      Found in diversipy/cube.py and 1 other location - About 1 day to fix
      diversipy/cube.py on lines 665..671

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if initial_points is None:
                points = sample_from_strata(stratify_generalized(num_points, dimension))
            elif len(initial_points) == num_points:
                points = np.array(initial_points)
                assert np.all(points >= 0.0)
        Severity: Major
        Found in diversipy/cube.py and 1 other location - About 5 hrs to fix
        diversipy/cube.py on lines 138..147

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if initial_points is None:
                cluster_centers = sample_from_strata(
                    stratify_generalized(num_points, dimension)
                )
            elif len(initial_points) == num_points:
        Severity: Major
        Found in diversipy/cube.py and 1 other location - About 5 hrs to fix
        diversipy/cube.py on lines 237..244

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            with np.errstate(divide="ignore"):
                if exponent == 0:
                    distances = np.log(1.0 / distances)
                else:
                    distances = 1.0 / (distances ** exponent)
        Severity: Major
        Found in diversipy/subset.py and 1 other location - About 2 hrs to fix
        diversipy/subset.py on lines 515..519

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                with np.errstate(divide="ignore"):
                    if exponent == 0:
                        distances = np.log(1.0 / distances)
                    else:
                        distances = 1.0 / (distances ** exponent)
        Severity: Major
        Found in diversipy/subset.py and 1 other location - About 2 hrs to fix
        diversipy/subset.py on lines 502..506

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if num_existing_points > 0:
                            dists_to_existing_points = distance_matrix(
                                removal_candidate_candidate, existing_points, **dist_args
                            )[0]
                            candidate_candidate_dist = min(
        Severity: Major
        Found in diversipy/cube.py and 1 other location - About 1 hr to fix
        diversipy/cube.py on lines 264..268

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if num_existing_points > 0:
                dists_to_existing_points = distance_matrix(
                    removal_candidate, existing_points, **dist_args
                )[0]
                current_dist = min(current_dist, dists_to_existing_points.min())
        Severity: Major
        Found in diversipy/cube.py and 1 other location - About 1 hr to fix
        diversipy/cube.py on lines 317..322

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

            if isinstance(points, list):
                return [points[i] for i in selected_indices]
            else:
                return np.take(points_array, selected_indices, axis=0)
        Severity: Major
        Found in diversipy/subset.py and 2 other locations - About 1 hr to fix
        diversipy/subset.py on lines 434..437
        diversipy/subset.py on lines 524..527

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 41.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language