bionc/bionc_numpy/inverse_kinematics.py

Summary

Maintainability
D
2 days
Test Coverage

File inverse_kinematics.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Callable

import numpy as np
from casadi import vertcat, horzcat, MX, Function, sum1

Severity: Major
Found in bionc/bionc_numpy/inverse_kinematics.py - About 1 day to fix

Function get_Q_init_from_initial_guess_mode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def get_Q_init_from_initial_guess_mode(
        self,
        initial_guess_mode: InitialGuessModeType,
        Q_init: np.ndarray | NaturalCoordinates,
        experimental_markers: np.ndarray,
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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 _solve_frame_per_frame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _solve_frame_per_frame(
        self,
        Q_init: np.ndarray | NaturalCoordinates,
        initial_guess_mode: InitialGuessModeType,
        method: str,
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        model: BiomechanicalModel,
        experimental_markers: np.ndarray | str = None,
        experimental_heatmaps: dict[str, np.ndarray] = None,
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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__(
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.py - About 45 mins to fix

Function _solve_frame_per_frame has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _solve_frame_per_frame(
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.py - About 35 mins to fix

Function update_initial_guess has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def update_initial_guess(
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.py - About 35 mins to fix

Function solve has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def solve(
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.py - About 35 mins to fix

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

    def _solve_all_frame_together(
        self,
        Q_init: np.ndarray | NaturalCoordinates,
        method: str,
        options: dict,
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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 add_objective has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_objective(self, objective_function: Callable):
        """

        This method adds an extra objective to the inverse kinematics problem. The objective function has to be a
        CasADi Function with the following signature: [objective_sym] = objective_function(Q_sym, markers_sym)
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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 check_segment_determinants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_segment_determinants(self):
        """Checks the determinant of each segment frame"""
        self.segment_determinants = np.zeros((self.model.nb_segments, self.nb_frames))
        for i in range(0, self.Qopt.shape[1]):
            Qi = NaturalCoordinatesNumpy(self.Qopt)[:, i : i + 1]
Severity: Minor
Found in bionc/bionc_numpy/inverse_kinematics.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