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

[RTM] show bounds test in ocp #728

Merged
merged 2 commits into from
Jul 20, 2023
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
32 changes: 32 additions & 0 deletions tests/test_plot_show_bounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from bioptim import BoundsList
from bioptim.limits.path_conditions import Bounds


def test_pendulum_show_bounds():
"""
It doesn"t test that bounds are shown, b
but we test that the bounds are added to the plot"
"""
from bioptim.examples.sqp_method import pendulum as ocp_module

bioptim_folder = os.path.dirname(ocp_module.__file__)

ocp = ocp_module.prepare_ocp(
biorbd_model_path=bioptim_folder + "/models/pendulum.bioMod",
final_time=1,
n_shooting=30,
assume_phase_dynamics=True,
)
# Test the keys in the dict ocp.nlp[0].plot
assert ["q_states", "qdot_states", "tau_controls"] == list(ocp.nlp[0].plot.keys())

for key, plot in ocp.nlp[0].plot.items():
assert isinstance(plot.bounds, Bounds)
assert plot.bounds.shape == (2, 3)
if "states" in key:
state = key.split("_")[0]
assert ocp.nlp[0].x_bounds[state] == plot.bounds
elif "controls" in key:
control = key.split("_")[0]
assert ocp.nlp[0].u_bounds[control] == plot.bounds
Loading