Skip to content

Commit

Permalink
test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
robfalck committed Nov 14, 2024
1 parent 0b354d5 commit 8a217f5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ def setup(self):

alt_data = USatm1976Data.alt * om.unit_conversion('ft', 'm')[0]
rho_data = USatm1976Data.rho * om.unit_conversion('slug/ft**3', 'kg/m**3')[0]

# Pad alt_data and rho_data to protect against solvers searching outside the valid range
alt_data = np.concatenate(([-1E6], alt_data))
rho_data = np.concatenate(([2.0], rho_data))

print(alt_data)
print(rho_data)
exit(0)


self.rho_interp = InterpND(points=np.array(alt_data),
values=np.array(rho_data),
method='slinear')
Expand Down
8 changes: 4 additions & 4 deletions dymos/transcriptions/common/test/test_control_interp_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_control_interp_scalar(self):
np.atleast_2d(b_rate2_expected).T)

np.set_printoptions(linewidth=1024)
cpd = p.check_partials(compact_print=False, method='cs')
cpd = p.check_partials(compact_print=False, method='cs', out_stream=None)
assert_check_partials(cpd)

def test_control_interp_vector(self, transcription='gauss-lobatto', compressed=True):
Expand Down Expand Up @@ -263,7 +263,7 @@ def test_control_interp_vector(self, transcription='gauss-lobatto', compressed=T
a2_rate2_expected)

np.set_printoptions(linewidth=1024)
cpd = p.check_partials(compact_print=True, method='cs')
cpd = p.check_partials(compact_print=True, method='cs', out_stream=None)

assert_check_partials(cpd)

Expand Down Expand Up @@ -362,7 +362,7 @@ def test_control_interp_matrix_3x1(self, transcription='gauss-lobatto', compress
a2_rate2_expected)

np.set_printoptions(linewidth=1024)
cpd = p.check_partials(compact_print=True, method='cs')
cpd = p.check_partials(compact_print=True, method='cs', out_stream=None)

assert_check_partials(cpd)

Expand Down Expand Up @@ -474,7 +474,7 @@ def test_control_interp_matrix_2x2(self, transcription='gauss-lobatto', compress
a3_rate2_expected)

with np.printoptions(linewidth=100000, edgeitems=100000):
cpd = p.check_partials(compact_print=True, method='cs')
cpd = p.check_partials(compact_print=True, method='cs', out_stream=None)

assert_check_partials(cpd)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_1_state_run_model(self):
prob.run_model()

with np.printoptions(linewidth=1024):
cpd = prob.check_partials(compact_print=True)
cpd = prob.check_partials(compact_print=True, out_stream=None)

assert_check_partials(cpd, rtol=1.0E-5)

Expand Down Expand Up @@ -157,7 +157,7 @@ def test_2_states_run_model(self):
assert_near_equal(y_f[-1, ...], 0.1691691, tolerance=1.0E-5)

with np.printoptions(linewidth=1024):
cpd = prob.check_partials(compact_print=True, method='fd')
cpd = prob.check_partials(compact_print=True, method='fd', out_stream=None)
assert_check_partials(cpd, atol=1.0E-5, rtol=1.0E-5)

dymos_options['include_check_partials'] = False
Expand Down Expand Up @@ -226,10 +226,10 @@ def test_brachistochrone_explicit_shooting(self):
assert_near_equal(t[-1, ...], 1.8016, tolerance=1.0E-2)

with np.printoptions(linewidth=1024):
cpd = prob.check_partials(compact_print=True, method='cs', excludes=['traj0.phases.phase0.integrator'])
cpd = prob.check_partials(compact_print=True, method='cs', excludes=['traj0.phases.phase0.integrator'], out_stream=None)
assert_check_partials(cpd, atol=1.0E-5, rtol=1.0E-5)

cpd = prob.check_partials(compact_print=True, method='fd', includes=['traj0.phases.phase0.integrator'])
cpd = prob.check_partials(compact_print=True, method='fd', includes=['traj0.phases.phase0.integrator'], out_stream=None)
assert_check_partials(cpd, atol=1.0E-5, rtol=1.0E-5)

dymos_options['include_check_partials'] = False
Expand Down Expand Up @@ -373,11 +373,11 @@ def test_brachistochrone_explicit_shooting_path_constraint_polynomial_control(se
assert_near_equal(t[-1, ...], 1.807379, tolerance=1.0E-5)

with np.printoptions(linewidth=1024):
cpd = prob.check_partials(compact_print=True, method='cs',
cpd = prob.check_partials(compact_print=True, method='cs', out_stream=None,
excludes=['traj0.phases.phase0.integrator'])
assert_check_partials(cpd, atol=1.0E-5, rtol=1.0E-5)

cpd = prob.check_partials(compact_print=True, method='fd',
cpd = prob.check_partials(compact_print=True, method='fd', out_stream=None,
includes=['traj0.phases.phase0.integrator'])
assert_check_partials(cpd, atol=1.0E-5, rtol=1.0E-5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,21 @@ def test_partials(self):
np.set_printoptions(linewidth=1024, edgeitems=1e1000)

p = self.make_prob('radau-ps', n_segs=2, order=5, compressed=False)
cpd = p.check_partials(compact_print=True, method='fd')
cpd = p.check_partials(compact_print=True, method='fd', out_stream=None)
del cpd['state_indep']
assert_check_partials(cpd)

p = self.make_prob('radau-ps', n_segs=2, order=5, compressed=True)
cpd = p.check_partials(compact_print=True, method='fd')
del cpd['state_indep']
cpd = p.check_partials(compact_print=True, method='fd', out_stream=None)
assert_check_partials(cpd)

p = self.make_prob('gauss-lobatto', n_segs=3, order=5, compressed=False)
cpd = p.check_partials(compact_print=True, method='fd')
cpd = p.check_partials(compact_print=True, method='fd', out_stream=None)
del cpd['state_indep']
assert_check_partials(cpd)

p = self.make_prob('gauss-lobatto', n_segs=4, order=3, compressed=True)
cpd = p.check_partials(compact_print=True, method='fd')
cpd = p.check_partials(compact_print=True, method='fd', out_stream=None)
del cpd['state_indep']
assert_check_partials(cpd)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_results(self):
tolerance=1.0E-9)

def test_partials(self):
cpd = self.p.check_partials(compact_print=False, method='cs')
cpd = self.p.check_partials(compact_print=False, method='cs', out_stream=None)
assert_check_partials(cpd)


Expand Down

0 comments on commit 8a217f5

Please sign in to comment.