Skip to content

Commit

Permalink
blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
EveCharbie committed Mar 1, 2024
1 parent dd13d3c commit 97e50d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bioptim/examples/getting_started/how_to_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import matplotlib.pyplot as plt
from bioptim.examples.getting_started.pendulum import prepare_ocp
from bioptim import Solver, SolutionMerge, TimeAlignment

"""
If pendulum is run as a script, it will perform the optimization and animates it
"""
Expand All @@ -23,7 +24,7 @@
decision_time = sol.decision_time(to_merge=SolutionMerge.NODES, time_alignment=TimeAlignment.STATES)
decision_states = sol.decision_states(to_merge=SolutionMerge.NODES)
for i in range(2):
axs[0, i].step(decision_time, decision_states["q"][i, :], label="Decision q", where='post')
axs[0, i].step(decision_time, decision_states["q"][i, :], label="Decision q", where="post")

# Retrieve stepwise states from the solution object.
stepwise_time = sol.stepwise_time(to_merge=SolutionMerge.NODES, time_alignment=TimeAlignment.STATES)
Expand All @@ -35,7 +36,7 @@
decision_time = sol.decision_time(to_merge=SolutionMerge.NODES, time_alignment=TimeAlignment.CONTROLS)
decision_controls = sol.decision_controls(to_merge=SolutionMerge.NODES)
for i in range(2):
axs[0, i].step(decision_time, decision_controls["tau"][i, :], label="Decision tau", where='post')
axs[0, i].step(decision_time, decision_controls["tau"][i, :], label="Decision tau", where="post")
axs[0, i].set_xlabel("Time [s]")
axs[0, i].grid(True)
axs[0, i].legend()
Expand All @@ -44,7 +45,7 @@
stepwise_time = sol.stepwise_time(to_merge=SolutionMerge.NODES, time_alignment=TimeAlignment.CONTROLS)
stepwise_controls = sol.stepwise_controls(to_merge=SolutionMerge.NODES)
for i in range(2):
axs[1, i].step(stepwise_time, stepwise_controls["tau"][i, :], label="Stepwise tau", where='post')
axs[1, i].step(stepwise_time, stepwise_controls["tau"][i, :], label="Stepwise tau", where="post")
axs[1, i].set_xlabel("Time [s]")
axs[1, i].grid(True)
axs[1, i].legend()
Expand Down
1 change: 1 addition & 0 deletions bioptim/examples/getting_started/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,6 @@ def main():
# sol.graphs(show_bounds=True)
sol.animate(n_frames=100)


if __name__ == "__main__":
main()

0 comments on commit 97e50d2

Please sign in to comment.