Skip to content

Commit

Permalink
Merge pull request #193 from moorepants/namespace
Browse files Browse the repository at this point in the history
Added __all__ from direct_collocation and utils to package namespace.
  • Loading branch information
moorepants authored Aug 3, 2024
2 parents bd0ef0e + 48b692f commit 1974457
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
10 changes: 3 additions & 7 deletions examples-gallery/plot_betts2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
"""

from collections import OrderedDict

import numpy as np
import sympy as sym
import matplotlib.pyplot as plt
from opty.direct_collocation import Problem
from opty import Problem

duration = 1.0
num_nodes = 100
Expand All @@ -39,7 +37,7 @@

# %%
# Specify the known system parameters.
par_map = OrderedDict()
par_map = {}
par_map[mu] = 60.0

# %%
Expand Down Expand Up @@ -101,7 +99,7 @@ def obj_grad(free):

# %%
# Plot results
fig_y1, axes_y1 = plt.subplots(3, 1)
fig_y1, axes_y1 = plt.subplots(3, 1, layout='constrained')

legend = ['measured', 'initial guess', 'direct collocation solution']

Expand Down Expand Up @@ -134,8 +132,6 @@ def obj_grad(free):
axes_y2[2].set_title('Solution Constraint Violations')
axes_y2[2].plot(prob.con(solution)[num_nodes - 1:])

plt.tight_layout()

# %%
prob.plot_constraint_violations(solution)

Expand Down
3 changes: 1 addition & 2 deletions examples-gallery/plot_drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
import sympy as sm
import sympy.physics.mechanics as me
import numpy as np
from opty.direct_collocation import Problem
from opty.utils import create_objective_function, parse_free
from opty import Problem, create_objective_function, parse_free
import matplotlib.pyplot as plt
import matplotlib.animation as animation

Expand Down
3 changes: 1 addition & 2 deletions examples-gallery/plot_one_legged_time_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
This example requires SymPy >= 1.13.
"""
from opty.direct_collocation import Problem
from opty.utils import parse_free
from opty import Problem, parse_free
from scipy.optimize import fsolve
import matplotlib.animation as animation
import matplotlib.pyplot as plt
Expand Down
3 changes: 1 addition & 2 deletions examples-gallery/plot_parallel_park.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
import numpy as np
import sympy as sm
import sympy.physics.mechanics as me
from opty.direct_collocation import Problem
from opty.utils import create_objective_function, parse_free
from opty import Problem, create_objective_function, parse_free
import matplotlib.pyplot as plt
import matplotlib.animation as animation

Expand Down
3 changes: 1 addition & 2 deletions examples-gallery/plot_pendulum_swing_up_fixed_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

import numpy as np
import sympy as sm
from opty.direct_collocation import Problem
from opty.utils import create_objective_function
from opty import Problem, create_objective_function
import matplotlib.pyplot as plt
import matplotlib.animation as animation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np
import sympy as sm
from opty.direct_collocation import Problem
from opty import Problem
import matplotlib.pyplot as plt
import matplotlib.animation as animation

Expand Down
2 changes: 1 addition & 1 deletion examples-gallery/plot_two_link_pendulum_on_a_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import numpy as np
import sympy as sm
import sympy.physics.mechanics as me
from opty.direct_collocation import Problem
from opty import Problem
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import patches
Expand Down
2 changes: 1 addition & 1 deletion examples/park2004/park2004.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
from scipy.integrate import odeint
from opty.direct_collocation import Problem
from opty import Problem
from opty.utils import sum_of_sines

from model import PlanarStandingHumanOnMovingPlatform
Expand Down
2 changes: 1 addition & 1 deletion examples/vyasarayani2011.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import sympy as sym
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from opty.direct_collocation import Problem
from opty import Problem
from opty.utils import building_docs


Expand Down
2 changes: 2 additions & 0 deletions opty/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

from .version import __version__
from .direct_collocation import *
from .utils import *
5 changes: 5 additions & 0 deletions opty/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
import_kwargs={'fromlist': ['']},
catch=(RuntimeError,))

__all__ = [
'parse_free',
'create_objective_function',
]


def _forward_jacobian(expr, wrt):

Expand Down

0 comments on commit 1974457

Please sign in to comment.