pyomeca/bioptim

View on GitHub

Showing 631 of 631 total issues

File configure_problem.py has 1850 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Callable, Any

import numpy as np
from casadi import vertcat, Function, DM

Severity: Major
Found in bioptim/dynamics/configure_problem.py - About 5 days to fix

    File optimal_control_program.py has 1506 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from math import inf
    from typing import Callable, Any
    
    import biorbd_casadi as biorbd
    import casadi
    Severity: Major
    Found in bioptim/optimization/optimal_control_program.py - About 4 days to fix

      Function _create_plots has a Cognitive Complexity of 171 (exceeds 5 allowed). Consider refactoring.
      Open

          def _create_plots(self, only_initialize_variables: bool):
              """
              Setup the plots
      
              Parameters
      Severity: Minor
      Found in bioptim/gui/plot.py - About 3 days 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

      File solution.py has 1261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import numpy as np
      from casadi import vertcat, DM, Function
      from copy import deepcopy
      from matplotlib import pyplot as plt
      from scipy import interpolate as sci_interp
      Severity: Major
      Found in bioptim/optimization/solution/solution.py - About 3 days to fix

        File penalty.py has 1154 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import inspect
        from typing import Any
        
        from casadi import horzcat, vertcat, Function, acos, dot, norm_fro, MX_eye, SX_eye, SX, jacobian, trace
        from math import inf
        Severity: Major
        Found in bioptim/limits/penalty.py - About 2 days to fix

          File path_conditions.py has 1140 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from typing import Callable, Any, List, Tuple
          
          import numpy as np
          from casadi import MX, SX, vertcat
          from scipy.interpolate import interp1d
          Severity: Major
          Found in bioptim/limits/path_conditions.py - About 2 days to fix

            File constraints.py has 1088 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from typing import Callable, Any
            
            import numpy as np
            from casadi import sum1, if_else, vertcat, lt, SX, MX, jacobian, Function, MX_eye, SX_eye, horzcat, ldl, diag
            
            
            Severity: Major
            Found in bioptim/limits/constraints.py - About 2 days to fix

              Function __set_costs has a Cognitive Complexity of 127 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __set_costs(self, ocp):
                      """
                      Set the cost functions from ocp
              
                      Parameters
              Severity: Minor
              Found in bioptim/interfaces/acados_interface.py - About 2 days 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

              File dynamics_functions.py has 1010 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from casadi import horzcat, vertcat, MX, SX, DM
              
              from .dynamics_evaluation import DynamicsEvaluation
              from .fatigue.fatigue_dynamics import FatigueList
              from ..misc.enums import DefectType
              Severity: Major
              Found in bioptim/dynamics/dynamics_functions.py - About 2 days to fix

                File biorbd_model.py has 958 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from typing import Callable
                
                import biorbd_casadi as biorbd
                import numpy as np
                from biorbd_casadi import (
                Severity: Major
                Found in bioptim/models/biorbd/biorbd_model.py - About 2 days to fix

                  File plot.py has 876 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import tkinter
                  from typing import Callable, Any
                  
                  import numpy as np
                  from casadi import DM
                  Severity: Major
                  Found in bioptim/gui/plot.py - About 2 days to fix

                    File multi_biorbd_model.py has 870 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import biorbd_casadi as biorbd
                    from casadi import MX, vertcat, Function, horzcat
                    from typing import Callable
                    
                    from .biorbd_model import BiorbdModel
                    Severity: Major
                    Found in bioptim/models/biorbd/multi_biorbd_model.py - About 2 days to fix

                      File penalty_option.py has 826 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from typing import Any, Callable
                      
                      import numpy as np
                      from casadi import vertcat, Function, MX, SX, jacobian, diag
                      
                      
                      Severity: Major
                      Found in bioptim/limits/penalty_option.py - About 1 day to fix

                        Function _process_time_vector has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _process_time_vector(
                                self,
                                time_resolution: TimeResolution,
                                to_merge: SolutionMerge | list[SolutionMerge],
                                time_alignment: TimeAlignment,
                        Severity: Minor
                        Found in bioptim/optimization/solution/solution.py - About 1 day 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

                        File receding_horizon_optimization.py has 755 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        from copy import deepcopy
                        from math import inf
                        from typing import Callable
                        from time import perf_counter
                        
                        
                        Severity: Major
                        Found in bioptim/optimization/receding_horizon_optimization.py - About 1 day to fix

                          File acados_interface.py has 741 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          from time import perf_counter
                          from datetime import datetime
                          
                          import numpy as np
                          from scipy import linalg
                          Severity: Major
                          Found in bioptim/interfaces/acados_interface.py - About 1 day to fix

                            Function _declare_cx_and_plot has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _declare_cx_and_plot(self):
                                    if self.as_states:
                                        for node_index in range(
                                            self.nlp.n_states_nodes if self.nlp.phase_dynamics == PhaseDynamics.ONE_PER_NODE else 1
                                        ):
                            Severity: Minor
                            Found in bioptim/dynamics/configure_new_variable.py - About 1 day 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

                            File arm_reaching_muscle_driven.py has 716 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            """
                            This example replicates the results from "An approximate stochastic optimal control framework to simulate nonlinear
                            neuro-musculoskeletal models in the presence of noise"(https://doi.org/10.1371/journal.pcbi.1009338).
                            The task is to unfold the arm to reach a target further from the trunk.
                            Noise is added on the motor execution (motor_noise) and on the feedback (wEE=wP and wEE_dot=wPdot).

                              File graph.py has 711 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import numpy as np
                              
                              from ..limits.constraints import Constraint
                              from ..limits.objective_functions import ObjectiveFcn, ObjectiveList, Objective
                              from ..limits.path_conditions import Bounds
                              Severity: Major
                              Found in bioptim/gui/graph.py - About 1 day to fix

                                BiorbdModel has 85 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                class BiorbdModel:
                                    """
                                    This class wraps the biorbd model and allows the user to call the biorbd functions from the biomodel protocol
                                    """
                                
                                
                                Severity: Major
                                Found in bioptim/models/biorbd/biorbd_model.py - About 1 day to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language