Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTR] catching when reading #861

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bioptim/dynamics/integrator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from casadi import Function, vertcat, horzcat, collocation_points, tangent, rootfinder, DM, MX, SX, linspace
import numpy as np
from casadi import Function, vertcat, horzcat, collocation_points, tangent, rootfinder, DM, MX, SX, linspace

from ..misc.enums import ControlType, DefectType
from ..models.protocols.biomodel import BioModel
Expand Down Expand Up @@ -170,7 +170,7 @@ def get_u(self, u: np.ndarray, t: float) -> np.ndarray:
The control at a given time
"""

if self.control_type == ControlType.CONSTANT or self.control_type == ControlType.CONSTANT_WITH_LAST_NODE:
if self.control_type in (ControlType.CONSTANT, ControlType.CONSTANT_WITH_LAST_NODE):
return u
elif self.control_type == ControlType.LINEAR_CONTINUOUS:
dt_norm = (t - self.t_span_sym[0]) / self.t_span_sym[1]
Expand Down Expand Up @@ -595,7 +595,7 @@ def get_u(self, u: np.ndarray, t: float | MX | SX) -> np.ndarray:
The control at a given time
"""

if self.control_type == ControlType.CONSTANT or self.control_type == ControlType.CONSTANT_WITH_LAST_NODE:
if self.control_type in (ControlType.CONSTANT, ControlType.CONSTANT_WITH_LAST_NODE):
return super(COLLOCATION, self).get_u(u, t)
else:
raise NotImplementedError(f"{self.control_type} ControlType not implemented yet with COLLOCATION")
Expand Down
Loading