Skip to content

Commit 7e24a7f

Browse files
authoredJan 19, 2024
removed bare matplotlib imports in non-test source files. (#1035)
1 parent 8bb2226 commit 7e24a7f

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed
 

‎dymos/examples/brachistochrone/test/ex_brachistochrone.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import matplotlib
21
import numpy as np
32

43
import openmdao.api as om
@@ -8,10 +7,6 @@
87
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE
98

109

11-
SHOW_PLOTS = True
12-
matplotlib.use('Agg')
13-
14-
1510
@require_pyoptsparse(optimizer='SLSQP')
1611
def brachistochrone_min_time(transcription='gauss-lobatto', num_segments=8, transcription_order=3,
1712
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,

‎dymos/examples/cart_pole/animate_cartpole.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import numpy as np
2-
import matplotlib.pyplot as plt
3-
import matplotlib.patches as patches
4-
from matplotlib import animation
52

63

74
def animate_cartpole(x, theta, force, interval=20, force_scaler=0.1, save_gif=False, gif_fps=20):
5+
6+
import matplotlib.pyplot as plt
7+
import matplotlib.patches as patches
8+
from matplotlib import animation
89
# x: time history of cart location, 1d vector
910
# theta: time history of pole angle, 1d vector
1011
# force: control input force

‎dymos/examples/plotting.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import matplotlib.pyplot as plt
2-
3-
41
def plot_results(axes, title, figsize=(10, 8), p_sol=None, p_sim=None):
52
"""
63
Plot the timeseries results of a Dymos problem using matplotlib.
@@ -22,6 +19,8 @@ def plot_results(axes, title, figsize=(10, 8), p_sol=None, p_sim=None):
2219
The Figure object and sequence of axes associated with the plot.
2320
2421
"""
22+
import matplotlib.pyplot as plt
23+
2524
nrows = len(axes)
2625

2726
fig, axs = plt.subplots(nrows=nrows, ncols=1, figsize=figsize)

‎dymos/visualization/timeseries_plots.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
import numpy as np
66

7-
import matplotlib
8-
import matplotlib.pyplot as plt
9-
import matplotlib.lines as mlines
10-
import matplotlib.patches as mpatches
11-
127
import openmdao.api as om
138
from .._options import options as dymos_options
149

@@ -55,6 +50,11 @@ def _get_phases_node_in_problem_metadata(node, path=""):
5550
def _mpl_timeseries_plots(time_units, var_units, phase_names, phases_node_path,
5651
last_solution_case, last_simulation_case, plot_dir_path,
5752
dpi, include_parameters):
53+
import matplotlib
54+
import matplotlib.pyplot as plt
55+
import matplotlib.lines as mlines
56+
import matplotlib.patches as mpatches
57+
5858
# get ready to plot
5959
backend_save = plt.get_backend()
6060
plt.switch_backend('Agg')

0 commit comments

Comments
 (0)