|
1 | 1 | """timeresp_test.py - test time response functions"""
|
2 | 2 |
|
3 | 3 | fromcopyimportcopy
|
| 4 | +frommathimportisclose |
4 | 5 |
|
5 | 6 | importnumpyasnp
|
6 | 7 | importpytest
|
7 | 8 | importscipyassp
|
8 | 9 |
|
9 | 10 | importcontrolasct
|
10 | 11 | fromcontrolimportStateSpace,TransferFunction,c2d,isctime,ss2tf,tf2ss
|
11 |
| -fromcontrol.exceptionimportslycot_check,pandas_check |
| 12 | +fromcontrol.exceptionimportpandas_check,slycot_check |
12 | 13 | fromcontrol.tests.conftestimportslycotonly
|
13 |
| -fromcontrol.timerespimport(_default_time_vector,_ideal_tfinal_and_dt, |
14 |
| -forced_response,impulse_response, |
15 |
| -initial_response,step_info,step_response) |
| 14 | +fromcontrol.timerespimport_default_time_vector,_ideal_tfinal_and_dt, \ |
| 15 | +forced_response,impulse_response,initial_response,step_info, \ |
| 16 | +step_response |
16 | 17 |
|
17 | 18 |
|
18 | 19 | classTSys:
|
@@ -1275,3 +1276,45 @@ def test_no_pandas():
|
1275 | 1276 | # Convert to pandas
|
1276 | 1277 | withpytest.raises(ImportError,match="pandas"):
|
1277 | 1278 | df=resp.to_pandas()
|
| 1279 | + |
| 1280 | + |
| 1281 | +# https://github.com/python-control/python-control/issues/1014 |
| 1282 | +deftest_step_info_nonstep(): |
| 1283 | +# Pass a constant input |
| 1284 | +timepts=np.linspace(0,10,endpoint=False) |
| 1285 | +y_const=np.ones_like(timepts) |
| 1286 | + |
| 1287 | +# Constant value of 1 |
| 1288 | +step_info=ct.step_info(y_const,timepts) |
| 1289 | +assertstep_info['RiseTime']==0 |
| 1290 | +assertstep_info['SettlingTime']==0 |
| 1291 | +assertstep_info['SettlingMin']==1 |
| 1292 | +assertstep_info['SettlingMax']==1 |
| 1293 | +assertstep_info['Overshoot']==0 |
| 1294 | +assertstep_info['Undershoot']==0 |
| 1295 | +assertstep_info['Peak']==1 |
| 1296 | +assertstep_info['PeakTime']==0 |
| 1297 | +assertstep_info['SteadyStateValue']==1 |
| 1298 | + |
| 1299 | +# Constant value of -1 |
| 1300 | +step_info=ct.step_info(-y_const,timepts) |
| 1301 | +assertstep_info['RiseTime']==0 |
| 1302 | +assertstep_info['SettlingTime']==0 |
| 1303 | +assertstep_info['SettlingMin']==-1 |
| 1304 | +assertstep_info['SettlingMax']==-1 |
| 1305 | +assertstep_info['Overshoot']==0 |
| 1306 | +assertstep_info['Undershoot']==0 |
| 1307 | +assertstep_info['Peak']==1 |
| 1308 | +assertstep_info['PeakTime']==0 |
| 1309 | +assertstep_info['SteadyStateValue']==-1 |
| 1310 | + |
| 1311 | +# Ramp from -1 to 1 |
| 1312 | +step_info=ct.step_info(-1+2*timepts/10,timepts) |
| 1313 | +assertstep_info['RiseTime']==3.8 |
| 1314 | +assertstep_info['SettlingTime']==9.8 |
| 1315 | +assertisclose(step_info['SettlingMin'],0.88) |
| 1316 | +assertisclose(step_info['SettlingMax'],0.96) |
| 1317 | +assertstep_info['Overshoot']==0 |
| 1318 | +assertstep_info['Peak']==1 |
| 1319 | +assertstep_info['PeakTime']==0 |
| 1320 | +assertisclose(step_info['SteadyStateValue'],0.96) |