IBM/pytorchpipe

View on GitHub

Showing 102 of 320 total issues

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

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

        :param config: Dictionary of parameters (read from configuration ``.yaml`` file).
Severity: Minor
Found in ptp/components/models/general_usage/feed_forward_network.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

Function setup_experiment has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setup_experiment(self):
        """
        Sets up experiment of all trainers:

        - Calls base class setup_experiment to parse the command line arguments,
Severity: Major
Found in ptp/workers/trainer.py - About 2 hrs to fix

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

        def __init__(self, name, config):
            """
            Constructor of the ``SimpleConvNet``. \
    
            The overall structure of this CNN is as follows:
    Severity: Major
    Found in ptp/components/models/vision/convnet_encoder.py - About 2 hrs to fix

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

          def __init__(self, name, config):
              """
              Initializes the ``LeNet5`` model, creates the required layers.
      
              :param name: Name of the model (taken from the configuration file).
      Severity: Minor
      Found in ptp/components/models/vision/generic_image_encoder.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 data_streams_gather has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def data_streams_gather(outputs, target_device, dim=0):
          r"""
          Gathers tensors from different GPUs on a specified device
            (-1 means the CPU).
          """
      Severity: Minor
      Found in ptp/utils/data_streams_parallel.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 42 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/vqa_med_2019.py - About 1 hr to fix

        Function __init__ has a Cognitive Complexity of 13 (exceeds 5 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

        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 13 (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/wikitext_language_modeling.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 build has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def build(self, log=True):
                """
                Method creates a task on the basis of configuration section.
        
                :param log: Logs information and the detected errors (DEFAULT: TRUE)
        Severity: Minor
        Found in ptp/application/task_manager.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 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def __call__(self, data_streams):
                """
                Encodes batch, or, in fact, only one field of batch ("inputs").
                Stores result in "outputs" field of data_streams.
        
        
        Severity: Minor
        Found in ptp/components/viewers/stream_viewer.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 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self): #, name, class_type, config):
                """
                Initializes the (word:index) mappings.
        
                Assumes that Component was initialized in advance, which means that the self object possesses the following objects:
        Severity: Minor
        Found in ptp/components/mixins/word_mappings.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 recurrent_config_parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def recurrent_config_parse(configs_to_parse: list, configs_parsed: list, abs_config_path: str):
            """
            Parses names of configuration files in a recursive manner, i.e. \
            by looking for ``default_config`` sections and trying to load and parse those \
            files one by one.
        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 calculate_statistics has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def calculate_statistics(self, data_streams):
                """
                Calculates confusion_matrix, precission, recall, f1score and support statistics.
        
                :param data_streams: DataStreams containing the targets.
        Severity: Minor
        Found in ptp/components/statistics/precision_recall_statistics.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __call__(self, data_streams):
                """
                Calculates precission recall statistics.
        
                :param data_streams: DataStreams containing the targets.
        Severity: Minor
        Found in ptp/components/statistics/precision_recall_statistics.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):
                """
                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 data_streams_scatter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def data_streams_scatter(inputs, target_gpus, dim=0):
            r"""
            Slices tensors into approximately equal chunks and
            distributes them across given GPUs. Duplicates
            references to objects that are not tensors.
        Severity: Minor
        Found in ptp/utils/data_streams_parallel.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):
                """
                Initializes the model, creates the required layers.
        
                :param name: Name of the model (taken from the configuration file).
        Severity: Minor
        Found in ptp/components/models/multi_modal_reasoning/relational_network.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 __getitem__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __getitem__(self, index):
                """
                Getter method to access the dataset and return a single sample.
        
                :param index: index of the sample to return.
        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 calculate_and_export_sample_weights has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def calculate_and_export_sample_weights(self, filename):
                """
                Method calculates and export weights associated with samples by looking at distribution of answers.
        
                :param filename: Name of the file (optionally with path) that the sample weights will be saved to.
        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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, name, config):
                """
                Initializes task object. Calls base constructor.
        
                :param name: Name of the component.
        Severity: Minor
        Found in ptp/components/tasks/text_to_class/wily_ngram_language_modeling.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

        Severity
        Category
        Status
        Source
        Language