IBM/pytorchpipe

View on GitHub

Showing 102 of 320 total issues

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

    def __init__(self, name, config):
        """
        Initializes the task.

        .. warning::
Severity: Minor
Found in ptp/components/tasks/image_to_class/simple_molecules.py - About 1 hr to fix

Cognitive Complexity

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

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

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

Further reading

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

    def __init__(self, name, config):
        """
        The init method downloads the required files, loads the file associated with a given subset (train/valid/test), 
        concatenates all sencentes and tokenizes them using NLTK's WhitespaceTokenizer.

Severity: Minor
Found in ptp/components/tasks/text_to_text/translation_pairs.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 get_value_list_from_dictionary has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def get_value_list_from_dictionary(key, parameter_dict, accepted_values = []):
    """
    Parses parameter values retrieved from a given parameter dictionary using key.
    Optionally, checks is all values are accepted.

Severity: Minor
Found in ptp/configuration/config_parsing.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 setup_individual_experiment has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setup_individual_experiment(self):
        """
        Setup individual test experiment in the case of multiple tests, or the main experiment in the case of \
        one test experiment.

Severity: Minor
Found in ptp/workers/processor.py - About 1 hr to fix

    Function forward has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def forward(self, data_streams):
            """
            Forward pass of the model.
    
            :param data_streams: DataStreams({'inputs', 'predictions ...}), where:
    Severity: Minor
    Found in ptp/components/models/general_usage/attention_decoder.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 random_remove_stop_words has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def random_remove_stop_words(self, words):
            """
            Function removes random stop words, each with 0.5 probability.
            
            :param words: tokenized text
    Severity: Minor
    Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, data_streams):
            """
            Encodes "inputs" in the format of a single tensor.
            Stores reshaped tensor in "outputs" field of in data_streams.
    
    
    Severity: Minor
    Found in ptp/components/transforms/list_to_tensor.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function __init__ has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, name, config):
            """
            Initializes task object. Calls base constructor. Downloads the dataset if not present and loads the adequate files depending on the mode.
    
            :param name: Name of the component.
    Severity: Minor
    Found in ptp/components/tasks/image_text_to_class/gqa.py - About 1 hr to fix

      Function __init__ has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, name, config):
              """
              Initializes task object. Calls base constructor. Downloads the dataset if not present and loads the adequate files depending on the mode.
      
              :param name: Name of the component.
      Severity: Minor
      Found in ptp/components/tasks/image_text_to_class/clevr.py - About 1 hr to fix

        Function __init__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(self, name, config):
                """
                Initializes the task.
        
                .. warning::
        Severity: Minor
        Found in ptp/components/tasks/image_to_class/cifar_100.py - About 1 hr to fix

          Function __init__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def __init__(self, name, config):
                  """
                  Initializes the model.
          
                  :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
          Severity: Minor
          Found in ptp/components/models/general_usage/attention_decoder.py - About 1 hr to fix

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

                def freeze_models(self):
                    """
                    Method analyses the configuration and freezes:
                        - all models when 'freeze' flag for whoe pipeline is set,
                        - individual models when their 'freeze' flags are set.
            Severity: Minor
            Found in ptp/application/pipeline_manager.py - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                def export_to_csv(self, csv_file=None):
                    """
                    Method writes current statistics to csv using the possessed formatting.
            
                    :param csv_file: File stream opened for writing, optional
            Severity: Minor
            Found in ptp/utils/statistics_collector.py - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                def set_leaf(self, leaf_key, leaf_value):
                    """
                    Update the value of the specified ``leaf_key`` of the current :py:class:`ConfigInterface` \
                    with the specified ``leaf_value``.
            
            
            Severity: Minor
            Found in ptp/configuration/config_interface.py - About 55 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, weights, num_samples, num_folds, epochs_per_fold = 1, all_but_current_fold = True, replacement=True):
            Severity: Minor
            Found in ptp/utils/samplers.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          for name, param in self.pipeline.named_parameters():
                                              try:
                                                  self.training_batch_writer.add_histogram(name + '/grad', 
                                                      param.grad.data.cpu().numpy(), self.app_state.episode, bins='doane')
              
              
              Severity: Major
              Found in ptp/workers/offline_trainer.py - About 45 mins to fix

                Function cuda has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def cuda(self):
                        """ 
                        Moves all models to GPU.
                        """
                        self.logger.info("Moving model(s) to GPU(s)")
                Severity: Minor
                Found in ptp/application/pipeline_manager.py - About 45 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 backward has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def backward(self, data_streams):
                        """
                        Propagates gradients backwards, starting from losses returned by every loss component in the pipeline.
                        If using many losses the components derived from loss must overwrite the ''loss_keys()'' method.
                
                
                Severity: Minor
                Found in ptp/application/pipeline_manager.py - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                        if log_errors:
                                            self.logger.error("Input definition: field '{}' in DataStreams has type {} different from expected (expected {} while received {})".format(key,index, id.types, dd.types))
                                        errors += 1
                Severity: Major
                Found in ptp/components/component.py - About 45 mins to fix

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

                      def __init__(self, name, config):
                          """
                          Initializes object. Loads keys and values of variables and adds them to globals.
                  
                          :param name: Loss name.
                  Severity: Minor
                  Found in ptp/components/publishers/global_variable_publisher.py - About 45 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