QInfer/python-qinfer

View on GitHub

Showing 3,465 of 3,465 total issues

File distributions.py has 1036 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# distributions.py: module for probability distributions.
##
Severity: Major
Found in src/qinfer/distributions.py - About 2 days to fix

    File smc.py has 784 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    ##
    # smc.py: Sequential Monte Carlo module
    ##
    Severity: Major
    Found in src/qinfer/smc.py - About 1 day to fix

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

      def heisenberg_weyl_operators(d=2):
          w = np.exp(2 * np.pi * 1j / d)
          X = qt.Qobj([
              qt.basis(d, (idx + 1) % d).data.todense().view(np.ndarray)[:, 0] for idx in range(d)
          ])
      Severity: Major
      Found in src/qinfer/tomography/expdesign.py and 1 other location - About 1 day to fix
      src/qinfer/tomography/models.py on lines 71..78

      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 175.

      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

      def heisenberg_weyl_operators(d=2):
          w = np.exp(2 * np.pi * 1j / d)
          X = qt.Qobj([
              qt.basis(d, (idx + 1) % d).data.todense().view(np.ndarray)[:, 0] for idx in range(d)
          ])
      Severity: Major
      Found in src/qinfer/tomography/models.py and 1 other location - About 1 day to fix
      src/qinfer/tomography/expdesign.py on lines 73..80

      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 175.

      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 derived_models.py has 673 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/python
      # -*- coding: utf-8 -*-
      ##
      # derived_models.py: Models that decorate and extend other models.
      ##
      Severity: Major
      Found in src/qinfer/derived_models.py - About 1 day to fix

        File test_distributions.py has 656 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/python
        # -*- coding: utf-8 -*-
        ##
        # test_distributions.py: Checks that distribution objects act as expected.
        ##
        Severity: Major
        Found in src/qinfer/tests/test_distributions.py - About 1 day to fix

          File abstract_model.py has 551 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #!/usr/bin/python
          # -*- coding: utf-8 -*-
          ##
          # abstract_model.py: Abstract interfaces for models with different levels of
          #     functionality.
          Severity: Major
          Found in src/qinfer/abstract_model.py - About 1 day to fix

            File domains.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/python
            # -*- coding: utf-8 -*-
            ##
            # domains.py: module for domains of model outcomes
            ##
            Severity: Major
            Found in src/qinfer/domains.py - About 1 day to fix

              File utils.py has 479 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/python
              # -*- coding: utf-8 -*-
              ##
              # utils.py : some auxiliary functions
              ##
              Severity: Minor
              Found in src/qinfer/utils.py - About 7 hrs to fix

                Function __init__ has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(
                            self, underlying_model, random_walk_idxs='all', 
                            fixed_covariance=None, diagonal=True, 
                            scale_mult=None, model_transformation=None
                        ):
                Severity: Minor
                Found in src/qinfer/derived_models.py - About 6 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

                    @property
                    def example_point(self):
                        """
                        Returns any single point guaranteed to be in the domain, but
                        no other guarantees; useful for testing purposes.
                Severity: Major
                Found in src/qinfer/domains.py and 1 other location - About 6 hrs to fix
                src/qinfer/domains.py on lines 505..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 99.

                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

                    @property
                    def example_point(self):
                        """
                        Returns any single point guaranteed to be in the domain, but
                        no other guarantees; useful for testing purposes.
                Severity: Major
                Found in src/qinfer/domains.py and 1 other location - About 6 hrs to fix
                src/qinfer/domains.py on lines 378..392

                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 99.

                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 base_test.py has 419 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/python
                # -*- coding: utf-8 -*-
                ##
                # base_test.py: Base class for derandomized test classes.
                ##
                Severity: Minor
                Found in src/qinfer/tests/base_test.py - About 6 hrs to fix

                  File test_concrete_models.py has 418 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #!/usr/bin/python
                  # -*- coding: utf-8 -*-
                  ##
                  # test_concrete_models.py: Checks that built-in instances of Model work properly.
                  ##
                  Severity: Minor
                  Found in src/qinfer/tests/test_concrete_models.py - About 6 hrs to fix

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

                        def instantiate_good_values(self):
                            return [
                                np.array([(0,[1,2,2])], dtype=[('','<i8'),('','<i8', 3)]),
                                np.array([(5,[5,0,0]),(0,[1,0,4])], dtype=[('','<i8'),('','<i8', 3)])
                    Severity: Major
                    Found in src/qinfer/tests/test_domains.py and 1 other location - About 4 hrs to fix
                    src/qinfer/tests/test_domains.py on lines 268..271

                    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 78.

                    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

                        def instantiate_bad_values(self):
                            return [
                                np.array([(-10,[1,2,2])], dtype=[('','<i8'),('k','<i8', 3)]),
                                np.array([(5,[-1,6,0]),(0,[1,0,4])], dtype=[('','<i8'),('k','<i8', 3)])
                    Severity: Major
                    Found in src/qinfer/tests/test_domains.py and 1 other location - About 4 hrs to fix
                    src/qinfer/tests/test_domains.py on lines 263..266

                    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 78.

                    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 design_expparams_field has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def design_expparams_field(self,
                                guess, field,
                                cost_scale_k=1.0, disp=False,
                                maxiter=None, maxfun=None,
                                store_guess=False, grad_h=None, cost_mult=False
                    Severity: Minor
                    Found in src/qinfer/expdesign.py - About 4 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

                    class TestMLEModel(ConcreteModelTest, DerandomizedTestCase):
                        """
                        Tests MLEModel with SimplePrecessionModel and 
                        a normal distribution at each step.
                        """
                    Severity: Major
                    Found in src/qinfer/tests/test_concrete_models.py and 1 other location - About 4 hrs to fix
                    src/qinfer/tests/test_concrete_models.py on lines 298..312

                    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 77.

                    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

                    class TestPoisonedModelALE(ConcreteModelTest, DerandomizedTestCase):
                        """
                        Tests PoisonedModel with SimplePrecessionModel as the underlying model
                        in ALE mode.
                        """
                    Severity: Major
                    Found in src/qinfer/tests/test_concrete_models.py and 1 other location - About 4 hrs to fix
                    src/qinfer/tests/test_concrete_models.py on lines 331..345

                    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 77.

                    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

                    Cyclomatic complexity is too high in method __init__. (20)
                    Open

                        def __init__(
                                self, underlying_model, random_walk_idxs='all', 
                                fixed_covariance=None, diagonal=True, 
                                scale_mult=None, model_transformation=None
                            ):
                    Severity: Minor
                    Found in src/qinfer/derived_models.py by radon

                    Cyclomatic Complexity

                    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                    Construct Effect on CC Reasoning
                    if +1 An if statement is a single decision.
                    elif +1 The elif statement adds another decision.
                    else +0 The else statement does not cause a new decision. The decision is at the if.
                    for +1 There is a decision at the start of the loop.
                    while +1 There is a decision at the while statement.
                    except +1 Each except branch adds a new conditional path of execution.
                    finally +0 The finally block is unconditionally executed.
                    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                    assert +1 The assert statement internally roughly equals a conditional statement.
                    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                    Source: http://radon.readthedocs.org/en/latest/intro.html

                    Severity
                    Category
                    Status
                    Source
                    Language