Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion control/modelsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def _expand_key(key):
Cr = Cr[keep_outputs, :]
Dr = Dr[keep_outputs, :][:, keep_inputs]

rsys = StateSpace(Ar, Br, Cr, Dr)
rsys = StateSpace(Ar, Br, Cr, Dr, sys.dt)
return rsys


Expand Down
16 changes: 16 additions & 0 deletions control/tests/modelsimp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,19 @@ def test_model_reduction(method, kwargs, nstates, noutputs, ninputs):
sys.A, sys.B[:, :ninputs], sys.C[:noutputs, :],
sys.D[:noutputs, :][:, :ninputs])
np.testing.assert_allclose(red(0), chk(0))


@pytest.mark.parametrize("dt", [0, None, True, 0.1])
@pytest.mark.parametrize("method, kwargs", [
('truncate', {'elim_states': [1]}),
('truncate', {'elim_states': [0, 1]}),
('truncate', {'elim_inputs': [1], 'elim_outputs': [1]}),
('matchdc', {'elim_inputs': [1], 'elim_outputs': [1]}),
])
def test_model_reduction_preserves_timebase(dt, method, kwargs):
sys = ct.ss([[-0.2, 0], [0, -0.5]], np.eye(2), np.eye(2),
np.zeros((2, 2)), dt=dt)
red = ct.model_reduction(sys, method=method, **kwargs)

assert red.dt == dt
assert type(red.dt) is type(dt)