Skip to content

Commit 448fb62

Browse files
committed
add unit test showing failure in #1087
1 parent a2c3b4c commit 448fb62

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

control/tests/timeresp_test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,13 +1247,14 @@ def test_to_pandas():
12471247
np.testing.assert_equal(df['x[1]'], resp.states[1])
12481248

12491249
# Change the time points
1250-
sys = ct.rss(2, 1, 1)
1250+
sys = ct.rss(2, 1, 2)
12511251
T = np.linspace(0, timepts[-1]/2, timepts.size * 2)
1252-
resp = ct.input_output_response(sys, timepts, np.sin(timepts), t_eval=T)
1252+
resp = ct.input_output_response(
1253+
sys, timepts, [np.sin(timepts), 0], t_eval=T)
12531254
df = resp.to_pandas()
12541255
np.testing.assert_equal(df['time'], resp.time)
1255-
np.testing.assert_equal(df['u[0]'], resp.inputs)
1256-
np.testing.assert_equal(df['y[0]'], resp.outputs)
1256+
np.testing.assert_equal(df['u[0]'], resp.inputs[0])
1257+
np.testing.assert_equal(df['y[0]'], resp.outputs[0])
12571258
np.testing.assert_equal(df['x[0]'], resp.states[0])
12581259
np.testing.assert_equal(df['x[1]'], resp.states[1])
12591260

@@ -1265,6 +1266,17 @@ def test_to_pandas():
12651266
np.testing.assert_equal(df['u[0]'], resp.inputs)
12661267
np.testing.assert_equal(df['y[0]'], resp.inputs * 5)
12671268

1269+
# https://github.com/python-control/python-control/issues/1087
1270+
model = ct.rss(
1271+
states=['x0', 'x1'], outputs=['y0', 'y1'],
1272+
inputs=['u0', 'u1'], name='My Model')
1273+
T = np.linspace(0, 10, 100, endpoint=False)
1274+
X0 = np.zeros(model.nstates)
1275+
res = ct.step_response(model, T=T, X0=X0, input=0)
1276+
df = res.to_pandas()
1277+
np.testing.assert_equal(df['time'], res.time)
1278+
np.testing.assert_equal(df['y1'], res.outputs['y1'])
1279+
12681280

12691281
@pytest.mark.skipif(pandas_check(), reason="pandas installed")
12701282
def test_no_pandas():

0 commit comments

Comments
 (0)