Skip to content

Conversation

@EastWest14
Copy link
Contributor

@EastWest14 EastWest14 commented May 1, 2025

#975

All Submissions:

  • Have you followed the guidelines in our Contributing document [docs/contribution.md]?
  • Have you checked to ensure there aren't other open [Pull Requests] for the same update/change?
  • Have you opened/linked the issue related to your pull request?
  • Have you used the tag [WIP] for on-going changes, and removed it when the pull request was ready?
  • When ready to merge, have you sent a comment pinging @pariterre in it?

New Feature Submissions:

  1. Does your submission pass the tests (if not please explain why this is intended)?
  2. Did you write a proper documentation (docstrings and ReadMe)
  3. Have you linted your code locally prior to submission (using the command: black . -l120 --exclude "external/*")?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new examples for your core changes, as applicable?
  • Have you written new tests for your core changes, as applicable?

This change is Reviewable

@EastWest14 EastWest14 force-pushed the convert_dynamics_fatigue branch from 9413250 to bacb753 Compare May 2, 2025 11:06
@EastWest14 EastWest14 changed the title [WIP]Fully converted dynamics fatigue. [WIP]Fully converted dynamics fatigue to new types May 2, 2025
@EastWest14 EastWest14 changed the title [WIP]Fully converted dynamics fatigue to new types [RTR]Fully converted dynamics fatigue to new types May 2, 2025
@EastWest14 EastWest14 mentioned this pull request May 2, 2025
Copy link
Collaborator

@EveCharbie EveCharbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG, this one should be easier ;)

Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 37 unresolved discussions (waiting on @EastWest14)


bioptim/dynamics/fatigue/muscle_fatigue.py line 48 at r1 (raw file):

        return MultiFatigueInterfaceMuscle

    def _get_target_load(self, nlp, controls, index):

controls: CX
index: Int
-> CX

Code quote:

def _get_target_load(self, nlp, controls, index):

bioptim/dynamics/fatigue/muscle_fatigue.py line 54 at r1 (raw file):

        return DynamicsFunctions.get(nlp.controls[self.type()], controls)[index, :]

    def dynamics(self, dxdt: MX, nlp, index: Int, states, controls) -> MX:

Same CX

Code quote:

def dynamics(self, dxdt: MX, nlp, index: Int, states, controls) -> MX:

bioptim/dynamics/fatigue/michaud_fatigue.py line 84 at r1 (raw file):

        return "tab:green", "tab:orange", "tab:red", "tab:brown"

    def default_initial_guess(self) -> IntTuple:

-> FloatTuple

Code quote:

def default_initial_guess(self) -> IntTuple:

bioptim/dynamics/fatigue/michaud_fatigue.py line 87 at r1 (raw file):

        return 0, 1, 0, 0

    def default_bounds(self, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

def default_bounds(self, variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/michaud_fatigue.py line 90 at r1 (raw file):

        return (0, 0, 0, 0), (1, 1, 1, 1)

    def apply_dynamics(self, target_load, *states):

target_load: CX
-> CX

Code quote:

def apply_dynamics(self, target_load, *states):

bioptim/dynamics/fatigue/effort_perception.py line 57 at r1 (raw file):

        return (0,), (1,)

    def apply_dynamics(self, target_load, *states):

target_load: CX
-> CX

Code quote:

def apply_dynamics(self, target_load, *states):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 47 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def suffix(variable_type: VariableType) -> AnyTuple:

StrTuple

Code quote:

def suffix(variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 54 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def color() -> AnyTuple:

-> StrTuple

Code quote:

def color() -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 72 at r1 (raw file):

    @abstractmethod
    def default_initial_guess(self) -> AnyTuple:

FloatTuple

Code quote:

def default_initial_guess(self) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 78 at r1 (raw file):

    @abstractmethod
    def default_bounds(self, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

def default_bounds(self, variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 98 at r1 (raw file):

    @abstractmethod
    def dynamics(self, dxdt: MX, nlp, index: int, states, controls) -> MX:

index: Int
states: CX
controls: CX
Actually, I am 80% sure all MX in the fatigue context could be changed to CX (the docstring could also be updated to MX | SX)

Code quote:

def dynamics(self, dxdt: MX, nlp, index: int, states, controls) -> MX:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 135 at r1 (raw file):

    def __init__(
        self,
        model: FatigueModel | AnyList,

list[FatigueModel]

Code quote:

model: FatigueModel | AnyList,

bioptim/dynamics/fatigue/fatigue_dynamics.py line 191 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def color() -> AnyTuple:

-> StrTuple

Code quote:

def color() -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 198 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def plot_factor() -> AnyTuple:

FloatTuple

Code quote:

def plot_factor() -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 204 at r1 (raw file):

    @abstractmethod
    def suffix(self) -> AnyTuple:

-> StrTuple

Code quote:

def suffix(self) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 209 at r1 (raw file):

        """

    def add(self, fatigue: FatigueModel):

-> None

Code quote:

def add(self, fatigue: FatigueModel):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 220 at r1 (raw file):

        self.models.append(fatigue)

    def dynamics(self, dxdt: MX, nlp, index: Int, states, controls) -> MX:

dxdt: CX
states: CX
controls: CX
-> CX

Code quote:

def dynamics(self, dxdt: MX, nlp, index: Int, states, controls) -> MX:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 227 at r1 (raw file):

    @abstractmethod
    def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: int, states, controls):

Same

Code quote:

def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: int, states, controls):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 252 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def default_state_only():

-> Bool

Code quote:

def default_state_only():

bioptim/dynamics/fatigue/fatigue_dynamics.py line 259 at r1 (raw file):

    @staticmethod
    @abstractmethod
    def default_apply_to_joint_dynamics():

-> Bool

Code quote:

def default_apply_to_joint_dynamics():

bioptim/dynamics/fatigue/fatigue_dynamics.py line 265 at r1 (raw file):

    @abstractmethod
    def default_bounds(self, index: Int, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

def default_bounds(self, index: Int, variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 282 at r1 (raw file):

    @abstractmethod
    def default_initial_guess(self, index: Int, variable_type: VariableType) -> Int:

-> FloatTuple

Code quote:

 -> Int:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 298 at r1 (raw file):

        """

    def _convert_to_models_key(self, item: IntOrStr):

-> Str

Code quote:

def _convert_to_models_key(self, item: IntOrStr):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 321 at r1 (raw file):

        return ("fatigue",)

    def default_bounds(self, index: Int, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

 def default_bounds(self, index: Int, variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 324 at r1 (raw file):

        return self.models["fatigue"].default_bounds(variable_type)

    def default_initial_guess(self, index: Int, variable_type: VariableType):

-> FloatTuple

Code quote:

def default_initial_guess(self, index: Int, variable_type: VariableType):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 327 at r1 (raw file):

        return self.models["fatigue"].default_initial_guess()

    def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: Int, states, controls):

Same CX

Code quote:

def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: Int, states, controls):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 335 at r1 (raw file):

    @staticmethod
    def plot_factor() -> IntTuple:

-> FloatTuple

Code quote:

def plot_factor() -> IntTuple:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 354 at r1 (raw file):

        self.suffix = suffix

    def add(self, **extra_arguments: Any):

-> None

Code quote:

 def add(self, **extra_arguments: Any):

bioptim/dynamics/fatigue/fatigue_dynamics.py line 370 at r1 (raw file):

        return self.options[self._iter_idx - 1][0] if self.options[self._iter_idx - 1] else None

    def dynamics(self, dxdt: MX, nlp, states, controls) -> MX:

Same CX

Code quote:

def dynamics(self, dxdt: MX, nlp, states, controls) -> MX:

bioptim/dynamics/fatigue/fatigue_dynamics.py line 413 at r1 (raw file):

        self.options[0][model.model_type()].add(model=model, phase=index)

    def dynamics(self, dxdt: MX, nlp, index: Int, states, controls):

Same CX

Code quote:

def dynamics(self, dxdt: MX, nlp, index: Int, states, controls):

bioptim/dynamics/fatigue/xia_fatigue.py line 51 at r1 (raw file):

        return "tab:green", "tab:orange", "tab:red"

    def default_initial_guess(self) -> StrTuple:

-> FloatTuple

Code quote:

def default_initial_guess(self) -> StrTuple:

bioptim/dynamics/fatigue/xia_fatigue.py line 54 at r1 (raw file):

        return 0, 1, 0

    def default_bounds(self, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

def default_bounds(self, variable_type: VariableType) -> AnyTuple:

bioptim/dynamics/fatigue/xia_fatigue.py line 65 at r1 (raw file):

        return "mf"

    def apply_dynamics(self, target_load: Float | CX, *states: Float | CX):

target_load: CX
states: CX
-> CX

Code quote:

def apply_dynamics(self, target_load: Float | CX, *states: Float | CX):

bioptim/dynamics/fatigue/tau_fatigue.py line 60 at r1 (raw file):

    @staticmethod
    def plot_factor() -> DoubleIntTuple:

FloatTuple

Code quote:

def plot_factor() -> DoubleIntTuple:

bioptim/dynamics/fatigue/tau_fatigue.py line 79 at r1 (raw file):

        """

    def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: Int, states, controls) -> MX:

Same CX

Code quote:

def _dynamics_per_suffix(self, dxdt: MX, suffix, nlp, index: Int, states, controls) -> MX:

bioptim/dynamics/fatigue/tau_fatigue.py line 93 at r1 (raw file):

        return dxdt

    def _get_target_load(self, var: FatigueModel, suffix: Str, nlp, controls, index: Int):

controls: CX
-> CX

Code quote:

def _get_target_load(self, var: FatigueModel, suffix: Str, nlp, controls, index: Int):

bioptim/dynamics/fatigue/tau_fatigue.py line 113 at r1 (raw file):

        return False

    def default_bounds(self, index: int, variable_type: VariableType) -> AnyTuple:

Tuple[FloatTuple]

Code quote:

def default_bounds(self, index: int, variable_type: VariableType) -> AnyTuple:

@EveCharbie EveCharbie changed the title [RTR]Fully converted dynamics fatigue to new types Fully converted dynamics fatigue to new types May 2, 2025
Copy link
Contributor Author

@EastWest14 EastWest14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 7 files reviewed, 37 unresolved discussions (waiting on @EveCharbie)


bioptim/dynamics/fatigue/effort_perception.py line 57 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

target_load: CX
-> CX

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 47 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

StrTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 72 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

FloatTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 78 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 98 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

index: Int
states: CX
controls: CX
Actually, I am 80% sure all MX in the fatigue context could be changed to CX (the docstring could also be updated to MX | SX)

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 135 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

list[FatigueModel]

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 191 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> StrTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 198 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

FloatTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 204 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> StrTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 209 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> None

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 220 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

dxdt: CX
states: CX
controls: CX
-> CX

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 227 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Same

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 252 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> Bool

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 265 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 298 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> Str

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 321 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 324 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> FloatTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 327 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Same CX

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 335 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> FloatTuple

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 354 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> None

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 370 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Same CX

Done.


bioptim/dynamics/fatigue/fatigue_dynamics.py line 413 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Same CX

Done.


bioptim/dynamics/fatigue/michaud_fatigue.py line 84 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> FloatTuple

Done.


bioptim/dynamics/fatigue/michaud_fatigue.py line 87 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/tau_fatigue.py line 60 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

FloatTuple

Done.


bioptim/dynamics/fatigue/tau_fatigue.py line 79 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Same CX

Done.


bioptim/dynamics/fatigue/tau_fatigue.py line 93 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

controls: CX
-> CX

Done.


bioptim/dynamics/fatigue/tau_fatigue.py line 113 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/xia_fatigue.py line 51 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

-> FloatTuple

Done.


bioptim/dynamics/fatigue/xia_fatigue.py line 54 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

Tuple[FloatTuple]

Done.


bioptim/dynamics/fatigue/xia_fatigue.py line 65 at r1 (raw file):

Previously, EveCharbie (Eve Charbonneau) wrote…

target_load: CX
states: CX
-> CX

Done.

@EastWest14 EastWest14 changed the title Fully converted dynamics fatigue to new types [RTR]Fully converted dynamics fatigue to new types May 2, 2025
@EastWest14 EastWest14 requested a review from EveCharbie May 2, 2025 14:24
EveCharbie
EveCharbie previously approved these changes May 5, 2025
Copy link
Collaborator

@EveCharbie EveCharbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks :)

Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @EastWest14)


bioptim/dynamics/fatigue/fatigue_dynamics.py line 98 at r1 (raw file):

Previously, EastWest14 (aprosikhin) wrote…

Done.

Done.

@EveCharbie EveCharbie changed the title [RTR]Fully converted dynamics fatigue to new types [RTM] Fully converted dynamics fatigue to new types May 5, 2025
@EveCharbie EveCharbie merged commit 8d7a8a2 into pyomeca:master May 5, 2025
19 of 22 checks passed
@EastWest14 EastWest14 deleted the convert_dynamics_fatigue branch May 5, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants