Skip to content

Commit 3bc9871

Browse files
committed
update naming conventions + initial unit tests
1 parent 85231b5 commit 3bc9871

2 files changed

Lines changed: 178 additions & 75 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""timeresp_return_test.py - test return values from time response functions
2+
3+
RMM, 22 Aug 2021
4+
5+
This set of unit tests covers checks to make sure that the various time
6+
response functions are returning the right sets of objects in the (new)
7+
InputOutputResponse class.
8+
9+
"""
10+
11+
import pytest
12+
13+
import numpy as np
14+
import control as ct
15+
16+
17+
def test_ioresponse_retvals():
18+
# SISO, single trace
19+
sys = ct.rss(4, 1, 1)
20+
T = np.linspace(0, 1, 10)
21+
U = np.sin(T)
22+
X0 = np.ones((sys.nstates,))
23+
24+
# Initial response
25+
res = ct.initial_response(sys, X0=X0)
26+
assert res.outputs.shape == (res.time.shape[0],)
27+
assert res.states.shape == (sys.nstates, res.time.shape[0])
28+
np.testing.assert_equal(res.inputs, np.zeros((res.time.shape[0],)))
29+
30+
# Impulse response
31+
res = ct.impulse_response(sys)
32+
assert res.outputs.shape == (res.time.shape[0],)
33+
assert res.states.shape == (sys.nstates, res.time.shape[0])
34+
assert res.inputs.shape == (res.time.shape[0],)
35+
np.testing.assert_equal(res.inputs, None)
36+
37+
# Step response
38+
res = ct.step_response(sys)
39+
assert res.outputs.shape == (res.time.shape[0],)
40+
assert res.states.shape == (sys.nstates, res.time.shape[0])
41+
assert res.inputs.shape == (res.time.shape[0],)
42+

0 commit comments

Comments
 (0)