diff --git a/bioptim/optimization/non_linear_program.py b/bioptim/optimization/non_linear_program.py index 1668d4d10..309af8757 100644 --- a/bioptim/optimization/non_linear_program.py +++ b/bioptim/optimization/non_linear_program.py @@ -304,6 +304,9 @@ def update_init( self, x_init: InitialGuessList | None, u_init: InitialGuessList | None, a_init: InitialGuessList | None ) -> None: + if u_init is not None and u_init.type == InterpolationType.ALL_POINTS: + raise ValueError("InterpolationType.ALL_POINTS cannot be used for control initial guesses") + if x_init is not None or a_init is not None: not_direct_collocation = not self.dynamics_type.ode_solver.is_direct_collocation x_init_all_point = x_init.type == InterpolationType.ALL_POINTS if x_init is not None else False diff --git a/tests/shard2/test_global_getting_started.py b/tests/shard2/test_global_getting_started.py index 073325241..dd87d4dd4 100644 --- a/tests/shard2/test_global_getting_started.py +++ b/tests/shard2/test_global_getting_started.py @@ -426,8 +426,8 @@ def test_initial_guesses(ode_solver, interpolation, random_init, phase_dynamics) np.random.seed(42) - if interpolation == InterpolationType.ALL_POINTS and ode_solver.is_direct_shooting: - with pytest.raises(ValueError, match="InterpolationType.ALL_POINTS must only be used with direct collocation"): + if interpolation == InterpolationType.ALL_POINTS: + with pytest.raises(ValueError, match="InterpolationType.ALL_POINTS cannot be used for control initial guesses"): _ = ocp_module.prepare_ocp( biorbd_model_path=bioptim_folder + "/examples/models/cube.bioMod", final_time=1,