iteal/wormpose

View on GitHub
wormpose/commands/evaluate_model.py

Summary

Maintainability
A
3 hrs
Test Coverage

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 _generate_synthetic_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _generate_synthetic_data(
    Severity: Minor
    Found in wormpose/commands/evaluate_model.py - About 45 mins to fix

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

      def _eval_data_gen(filenames: List[str]):
          for filename in filenames:
              with open(filename, "rb") as f:
                  while True:
                      try:
      Severity: Minor
      Found in wormpose/commands/evaluate_model.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

      There are no issues that match your filters.

      Category
      Status