diff --git a/bioptim/examples/getting_started/how_to_plot.py b/bioptim/examples/getting_started/how_to_plot.py index 624f01933..c7c972c59 100644 --- a/bioptim/examples/getting_started/how_to_plot.py +++ b/bioptim/examples/getting_started/how_to_plot.py @@ -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 """ @@ -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) @@ -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() @@ -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() diff --git a/bioptim/examples/getting_started/pendulum.py b/bioptim/examples/getting_started/pendulum.py index 550488c6f..b936f9c5f 100644 --- a/bioptim/examples/getting_started/pendulum.py +++ b/bioptim/examples/getting_started/pendulum.py @@ -152,5 +152,6 @@ def main(): # sol.graphs(show_bounds=True) sol.animate(n_frames=100) + if __name__ == "__main__": main()