iteal/wormpose

View on GitHub

Showing 45 of 47 total issues

File postprocess_results.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

"""
Post-processes WormPose results by interpolating over missing frames and smoothing
"""
Severity: Minor
Found in wormpose/commands/postprocess_results.py - About 2 hrs to fix

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

    def _compare_pred_real(
        frame_preprocessing: BaseFramePreprocessing,
        data_reading_queue,
        results_queue,
        image_shape,
    Severity: Minor
    Found in wormpose/images/scoring/results_scoring.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 load_dataset has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_dataset(
        dataset_loader: str,
        dataset_path: str,
        selected_video_names: Optional[List[str]] = None,
        resize_options: ResizeOptions = None,
    Severity: Minor
    Found in wormpose/dataset/loader.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 _parse_arguments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_arguments(dataset_path: str, kwargs: dict):
        if kwargs.get("work_dir") is None:
            kwargs["work_dir"] = default_paths.WORK_DIR
        if kwargs.get("num_process") is None:
            kwargs["num_process"] = os.cpu_count()
    Severity: Minor
    Found in wormpose/commands/evaluate_model.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 evaluate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def evaluate(dataset_path: str, **kwargs):
        """
        Evaluate a trained model by predicting synthetic data and recording the image similarity
    
        :param dataset_path: Root path of the dataset containing videos of worm
    Severity: Minor
    Found in wormpose/commands/evaluate_model.py - About 1 hr to fix

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

      def _make_continuous_partitions(
          shuffled_results: ShuffledResults, score_threshold: float, frame_rate: float
      ) -> _PartitionedResults:
          time_window = max(1, int(frame_rate * CONTINOUS_SEGMENT_TIME_WINDOW_SEC))
          min_segment_size = max(1, int(frame_rate * MIN_SEGMENT_SIZE_SEC))
      Severity: Minor
      Found in wormpose/pose/headtail_resolution.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 post_process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def post_process(dataset_path: str, **kwargs):
          """
          Process the raw network results with interpolation and smoothing
      
          :param dataset_path: Root path of the dataset containing videos of worm
      Severity: Minor
      Found in wormpose/commands/postprocess_results.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 save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def save(self, results: dict, video_name: str, metadata: Optional[dict] = None):
              results_folder = os.path.join(self.results_root_dir, video_name)
              if not os.path.exists(results_folder):
                  os.mkdir(results_folder)
      
      
      Severity: Minor
      Found in wormpose/commands/utils/results_saver.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 generate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate(
              self,
              theta: np.ndarray,
              template_frame: np.ndarray,
              template_skeleton: np.ndarray,
      Severity: Minor
      Found in wormpose/images/synthetic/synthetic_dataset.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 _write_to_file has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _write_to_file(
      Severity: Major
      Found in wormpose/machine_learning/synthetic_data_generator.py - About 1 hr to fix

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

            def __init__(
        Severity: Major
        Found in wormpose/config/experiment_config.py - About 1 hr to fix

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

          def _align_segments_with_labels(segments, partitioned_skeletons, labelled_skeletons, min_labelled=5):
              """
              Match the head/tail alignment with the results of the classical tracking in each of the segments,
               if there is enough labelled data in the segment
              """
          Severity: Minor
          Found in wormpose/pose/headtail_resolution.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def export(self, video_name: str, **kwargs):
          
                  timestamp = kwargs["dataset"].features_dataset[video_name].timestamp
                  results_skeletons: np.ndarray = kwargs["results_skeletons"]
                  out_dir: str = kwargs["out_dir"]
          Severity: Minor
          Found in wormpose/dataset/loaders/tierpsy/results_exporter.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 _parse_arguments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def _parse_arguments(kwargs: dict):
              if kwargs.get("num_process") is None:
                  kwargs["num_process"] = os.cpu_count()
              if kwargs.get("temp_dir") is None:
                  kwargs["temp_dir"] = tempfile.gettempdir()
          Severity: Minor
          Found in wormpose/commands/generate_training_data.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 _parse_arguments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def _parse_arguments(dataset_path: str, kwargs: dict):
              if kwargs.get("work_dir") is None:
                  kwargs["work_dir"] = default_paths.WORK_DIR
              if kwargs.get("max_gap_size") is None:
                  kwargs["max_gap_size"] = 4
          Severity: Minor
          Found in wormpose/commands/postprocess_results.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 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in wormpose/machine_learning/synthetic_data_generator.py - About 50 mins to fix

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

            def _validate_features(raw_features: dict):
                if not (
                    len(raw_features["skeletons"])
                    == len(raw_features["head_width"])
                    == len(raw_features["midbody_width"])
            Severity: Minor
            Found in wormpose/dataset/features.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Minor
            Found in wormpose/dataset/loader.py - About 45 mins to fix

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

              def _align_unlabelled_segments_with_adjacents(segments, segments_alignment, partitioned_skeletons, frame_rate: float):
                  """
                  Resolve the unaligned segments by comparing with adjacent segments,
                  starting with the segments that have the least frames gap between an adjacent trusted segment
                  Don't align isolated segments which a big gap between trusted segments
              Severity: Minor
              Found in wormpose/pose/headtail_resolution.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 generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def generate(self, file_pattern: str, num_samples: int):
                      """
                      Start the generation of files containing synthetic data
              
                      :param file_pattern: Filepath of the files to generate with an "index" variable
              Severity: Minor
              Found in wormpose/machine_learning/synthetic_data_generator.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