Skip to content

Commit

Permalink
address review: allclose broadcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed Mar 25, 2021
1 parent 97e08c6 commit 66b381f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,7 @@ def test_time_vector(self, tsystem, fun, squeeze, matarrayout):
# tout should always match t, which has shape (n, )
np.testing.assert_allclose(tout, tsystem.t)
elif fun == forced_response and sys.dt in [None, True]:
np.testing.assert_allclose(
np.diff(tout), np.full_like(tout[:-1], 1.))
np.testing.assert_allclose(np.diff(tout), 1.)

if squeeze is False or not sys.issiso():
assert yout.shape[0] == sys.noutputs
Expand Down
3 changes: 1 addition & 2 deletions control/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,

# equally spaced also implies strictly monotonic increase
dt = T[1] - T[0]
if not np.allclose(np.diff(T), np.full_like(T[:-1], dt)):
if not np.allclose(np.diff(T), dt):
raise ValueError("Parameter ``T``: time values must be "
"equally spaced.")
n_steps = T.shape[0] # number of simulation steps
Expand All @@ -365,7 +365,6 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
X0 = _check_convert_array(X0, [(n_states,), (n_states, 1)],
'Parameter ``X0``: ', squeeze=True)


xout = np.zeros((n_states, n_steps))
xout[:, 0] = X0
yout = np.zeros((n_outputs, n_steps))
Expand Down

0 comments on commit 66b381f

Please sign in to comment.