IBM/pytorchpipe

View on GitHub

Showing 320 of 320 total issues

Avoid too many return statements within this function.
Open

        return type(out)(map(gather_map, zip(*outputs)))
Severity: Major
Found in ptp/utils/data_streams_parallel.py - About 30 mins to fix

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

        def input_data_definitions(self):
            """ 
            Function returns a dictionary with definitions of input data that are required by the component.
    
            :return: dictionary containing input data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
    Severity: Minor
    Found in ptp/components/models/language/sentence_embeddings.py and 1 other location - About 30 mins to fix
    ptp/components/language/sentence_one_hot_encoder.py on lines 48..55

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

    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 input_data_definitions(self):
            """ 
            Function returns a dictionary with definitions of input data that are required by the component.
    
            :return: dictionary containing input data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
    Severity: Minor
    Found in ptp/components/language/sentence_one_hot_encoder.py and 1 other location - About 30 mins to fix
    ptp/components/models/language/sentence_embeddings.py on lines 80..87

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

    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

    Avoid too many return statements within this function.
    Open

            return [obj for _ in target_gpus]
    Severity: Major
    Found in ptp/utils/data_streams_parallel.py - About 30 mins to fix

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

                  self.rnn_cell_dec = getattr(torch.nn, self.cell_type)(self.input_size, self.hidden_size, self.num_layers, batch_first=True)
      Severity: Minor
      Found in ptp/components/models/general_usage/seq2seq.py and 1 other location - About 30 mins to fix
      ptp/components/models/general_usage/seq2seq.py on lines 78..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 32.

      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

                  self.logger.info("Generated {} n-grams, example:\n{}".format(len(self.ngrams_sent), self.ngrams_sent[0]))
      ptp/components/tasks/text_to_class/wily_ngram_language_modeling.py on lines 104..104

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

      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

                  self.rnn_cell_enc = getattr(torch.nn, self.cell_type)(self.input_size, self.hidden_size, self.num_layers, batch_first=True)
      Severity: Minor
      Found in ptp/components/models/general_usage/seq2seq.py and 1 other location - About 30 mins to fix
      ptp/components/models/general_usage/seq2seq.py on lines 79..79

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

      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

                  self.logger.info("Loaded {} n-grams, example:\n{}".format(len(self.ngrams_sent), self.ngrams_sent[0]))
      ptp/components/tasks/text_to_class/wily_ngram_language_modeling.py on lines 91..91

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

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

          def output_data_definitions(self):
              """ 
              Function returns a dictionary with definitions of output data produced the component.
      
              :return: dictionary containing output data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
      Severity: Minor
      Found in ptp/components/models/general_usage/recurrent_neural_network.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def calculate_accuracy(self, data_streams):
              """
              Calculates accuracy equal to mean number of correct classification in a given batch.
      
              :param data_streams: DataStreams containing the targets.
      Severity: Minor
      Found in ptp/components/statistics/accuracy_statistics.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def load_testset_without_answers(self, data_file, image_folder):
              """
              Loads the test set without answers.
      
              :param data_file: Source file.
      Severity: Minor
      Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def export_to_csv(self, csv_file=None):
              """
              This method writes the current statistical aggregators values to the `csv_file` using the associated formatting.
      
              :param csv_file: File stream opened for writing, optional.
      Severity: Minor
      Found in ptp/utils/statistics_aggregator.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def set_types(self):
              """
              Enables computations on CUDA if GPU is available.
              Sets the default data types.
              """
      Severity: Minor
      Found in ptp/utils/app_state.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def build(name, config):
              """
              Method creates a single component on the basis of configuration section.
              Raises ConfigurationError exception when encountered issues.
      
      
      Severity: Minor
      Found in ptp/application/component_factory.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def export_to_checkpoint(self):
              """
              This method exports the collected data into a dictionary using the associated formatting.
      
              """
      Severity: Minor
      Found in ptp/utils/statistics_collector.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def input_data_definitions(self):
              """ 
              Function returns a dictionary with definitions of input data that are required by the component.
      
              :return: dictionary containing input data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
      Severity: Minor
      Found in ptp/components/models/general_usage/recurrent_neural_network.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def sentences_to_tensor(self, data_streams):
              """
              Encodes "inputs" in the format of batch of list of words into a single tensor with corresponding indices.
      
              :param data_streams: :py:class:`ptp.datatypes.DataStreams` object containing (among others):
      Severity: Minor
      Found in ptp/components/language/sentence_indexer.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def load_dataset(self, source_files, source_image_folders, source_categories):
              """
              Loads the dataset from one or more files.
      
              :param source_files: List of source files.
      Severity: Minor
      Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

      def pad_trunc_list(l: list, length: int, padding_value = 0, eos_value = None):
          """
          Will apply padding / clipping to list to meet requested length.
          Works on the list in-place.
      
      
      Severity: Minor
      Found in ptp/components/mixins/word_mappings.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def to(self, device=None, keys_to_move=None, non_blocking=False):
              """
              Moves object(s) to device
      
              .. note::
      Severity: Minor
      Found in ptp/data_types/data_streams.py - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language