sylvchev/mdla

View on GitHub

Showing 119 of 119 total issues

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

def _generate_testbed(
    kernel_init_len,
    n_nonzero_coefs,
    n_kernels,
    n_samples=10,
Severity: Major
Found in examples/example_multivariate.py and 1 other location - About 3 days to fix
examples/example_univariate.py on lines 70..114

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

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 _generate_testbed(
    kernel_init_len,
    n_nonzero_coefs,
    n_kernels,
    n_samples=10,
Severity: Major
Found in examples/example_univariate.py and 1 other location - About 3 days to fix
examples/example_multivariate.py on lines 62..106

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

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 _generate_testbed(
    kernel_init_len,
    n_nonzero_coefs,
    n_kernels,
    n_samples=10,
Severity: Major
Found in experiments/experiment_dictionary_recovering.py and 1 other location - About 3 days to fix
experiments/experiment_multivariate_recovering.py on lines 23..67

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

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 _generate_testbed(
    kernel_init_len,
    n_nonzero_coefs,
    n_kernels,
    n_samples=10,
Severity: Major
Found in experiments/experiment_multivariate_recovering.py and 1 other location - About 3 days to fix
experiments/experiment_dictionary_recovering.py on lines 14..58

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

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

""" Multivariate dictionary learning"""
# Author: Sylvain Chevallier
# License: GPL v3

import itertools
Severity: Major
Found in mdla/mdla.py - About 3 days to fix

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

    def callback_distance(loc):
        ii, iter_offset = loc["ii"], loc["iter_offset"]
        n_batches = loc["n_batches"]
        if np.mod((ii - iter_offset) / int(n_batches), n_iter) == 0:
            # Compute distance only every 5 iterations, as in previous case
    Severity: Major
    Found in examples/example_multivariate.py and 1 other location - About 1 day to fix
    examples/example_univariate.py on lines 169..179

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

    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 callback_distance(loc):
        ii, iter_offset = loc["ii"], loc["iter_offset"]
        n_batches = loc["n_batches"]
        if np.mod((ii - iter_offset) / int(n_batches), n_iter) == 0:
            # Compute distance only every 5 iterations, as in previous case
    Severity: Major
    Found in examples/example_univariate.py and 1 other location - About 1 day to fix
    examples/example_multivariate.py on lines 161..171

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

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

    # -*- coding: utf-8 -*-
    """
    The `dict_metrics` module implements utilities to compare
    frames and dictionaries.
    
    
    Severity: Minor
    Found in mdla/dict_metrics.py - About 5 hrs to fix

      Function multivariate_dict_learning has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      def multivariate_dict_learning(
          X,
          n_kernels,
          n_nonzero_coefs=1,
          max_iter=100,
      Severity: Minor
      Found in mdla/mdla.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 read_BCI_signals has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

      def read_BCI_signals():
          kppath = "../../datasets/BCIcompetition4/"
          lkp = listdir(kppath)
          sujets = list()
          classes = list()
      Severity: Minor
      Found in experiments/experiment_bci_competition.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 _multivariate_OMP has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

      def _multivariate_OMP(signal, dictionary, n_nonzero_coefs=None, verbose=False):
          """Sparse coding multivariate signal with OMP
      
          Returns residual and a decomposition array (n_nonzero_coefs, 3),
          each line indicating (amplitude, offset, kernel).
      Severity: Minor
      Found in mdla/mdla.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 multivariate_dict_learning_online has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

      def multivariate_dict_learning_online(
          X,
          n_kernels=2,
          n_nonzero_coefs=1,
          n_iter=100,
      Severity: Minor
      Found in mdla/mdla.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

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

      for _ in range(max_iter):
          learned_dict = learned_dict.partial_fit(X)
          # Compute the detection rate
          detect_rate.append(detection_rate(learned_dict.kernels_, generating_dict, 0.99))
          # Compute the Wasserstein distance
      Severity: Major
      Found in examples/example_univariate.py and 1 other location - About 4 hrs to fix
      examples/example_multivariate.py on lines 142..149

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

      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

      for _ in range(max_iter):
          learned_dict = learned_dict.partial_fit(X)
          # Compute the detection rate
          detect_rate.append(detection_rate(learned_dict.kernels_, generating_dict, 0.99))
          # Compute the Wasserstein distance
      Severity: Major
      Found in examples/example_multivariate.py and 1 other location - About 4 hrs to fix
      examples/example_univariate.py on lines 150..157

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

      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 3 locations. Consider refactoring.
      Open

              metwass.annotate(
                  "SNR " + s,
                  xy=(0.51, 1.0 - i * 1.0 / 3.0 + i * 0.01 - 0.001),
      Severity: Major
      Found in experiments/experiment_multivariate_recovering.py and 2 other locations - About 3 hrs to fix
      experiments/experiment_dictionary_recovering.py on lines 187..189
      experiments/experiment_multivariate_recovering.py on lines 185..187

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

      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 3 locations. Consider refactoring.
      Open

              metwass.annotate(
                  "SNR " + s,
                  xy=(0.51, 1.0 - i * 1.0 / 3.0 + i * 0.01 - 0.001),
      Severity: Major
      Found in experiments/experiment_multivariate_recovering.py and 2 other locations - About 3 hrs to fix
      experiments/experiment_dictionary_recovering.py on lines 187..189
      experiments/experiment_multivariate_recovering.py on lines 128..130

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

      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 3 locations. Consider refactoring.
      Open

              metbeta.annotate(
                  "SNR " + s,
                  xy=(0.51, 1.0 - i * 1.0 / 3.0 + i * 0.01 - 0.001),
      Severity: Major
      Found in experiments/experiment_dictionary_recovering.py and 2 other locations - About 3 hrs to fix
      experiments/experiment_multivariate_recovering.py on lines 128..130
      experiments/experiment_multivariate_recovering.py on lines 185..187

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

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

      """Dictionary recovering experiment for multivariate random dataset"""
      import os
      import pickle
      from os.path import exists
      
      
      Severity: Minor
      Found in experiments/experiment_multivariate_recovering.py - About 2 hrs to fix

        File experiment_dictionary_recovering.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Dictionary recovering experiment for univariate random dataset"""
        import pickle
        from os.path import exists
        
        import matplotlib.pyplot as plt
        Severity: Minor
        Found in experiments/experiment_dictionary_recovering.py - About 2 hrs to fix

          Function plot_kernels has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          def plot_kernels(
              kernels,
              n_kernels,
              col=5,
              row=-1,
          Severity: Minor
          Found in examples/plot_bci_dict.py - About 2 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

          Severity
          Category
          Status
          Source
          Language