Skip to content

Commit 4afda82

Browse files
committed
updated unit tests
1 parent b881b22 commit 4afda82

19 files changed

Lines changed: 497 additions & 439 deletions

control/bdalg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def negate(sys):
202202
return -sys
203203

204204
#! TODO: expand to allow sys2 default to work in MIMO case?
205+
#! TODO: allow renaming of signals (for all bdalg operations)
205206
def feedback(sys1, sys2=1, sign=-1):
206207
"""
207208
Feedback interconnection between two I/O systems.
@@ -254,6 +255,7 @@ def feedback(sys1, sys2=1, sign=-1):
254255
255256
"""
256257
# Allow anything with a feedback function to call that function
258+
# TODO: rewrite to allow __rfeedback__
257259
try:
258260
return sys1.feedback(sys2, sign)
259261
except AttributeError:

control/iosys.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,13 @@ def isctime(sys, strict=False):
599599
# Utility function to parse nameio keywords
600600
def _process_iosys_keywords(
601601
keywords={}, defaults={}, static=False, end=False):
602-
"""Process iosys specification
602+
"""Process iosys specification.
603603
604-
This function processes the standard keywords used in initializing a named
605-
I/O system. It first looks in the `keyword` dictionary to see if a value
606-
is specified. If not, the `default` dictionary is used. The `default`
607-
dictionary can also be set to a InputOutputSystem object, which is useful for
608-
copy constructors that change system and signal names.
604+
This function processes the standard keywords used in initializing an
605+
I/O system. It first looks in the `keyword` dictionary to see if a
606+
value is specified. If not, the `default` dictionary is used. The
607+
`default` dictionary can also be set to an InputOutputSystem object,
608+
which is useful for copy constructors that change system/signal names.
609609
610610
If `end` is True, then generate an error if there are any remaining
611611
keywords.

control/matlab/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262

6363
# Control system library
6464
from ..statesp import *
65-
from ..statesp import ss, rss, drss # moved from .statesp
6665
from ..xferfcn import *
6766
from ..lti import *
6867
from ..iosys import *

control/nlsys.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from . import config
3535
from .iosys import InputOutputSystem, _process_signal_list, \
3636
_process_iosys_keywords, isctime, isdtime, common_timebase, _parse_spec
37+
from .timeresp import _check_convert_array, _process_time_response, \
38+
TimeResponseData
3739

3840
__all__ = ['NonlinearIOSystem', 'InterconnectedSystem',
3941
'input_output_response', 'find_eqpt', 'linearize',
@@ -174,8 +176,6 @@ def __call__(sys, u, params=None, squeeze=None):
174176
value set by config.defaults['control.squeeze_time_response'].
175177
176178
"""
177-
from .timeresp import _process_time_response
178-
179179
# Make sure the call makes sense
180180
if not sys._isstatic():
181181
raise TypeError(
@@ -598,7 +598,6 @@ def __init__(self, syslist, connections=None, inplist=None, outlist=None,
598598
params=None, warn_duplicate=None, **kwargs):
599599
"""Create an I/O system from a list of systems + connection info."""
600600
from .statesp import _convert_to_statespace
601-
from .statesp import StateSpace, LinearICSystem
602601
from .xferfcn import TransferFunction
603602

604603
# Convert input and output names to lists if they aren't already
@@ -1238,9 +1237,6 @@ def input_output_response(
12381237
results.
12391238
12401239
"""
1241-
from .timeresp import _check_convert_array, _process_time_response, \
1242-
TimeResponseData
1243-
12441240
#
12451241
# Process keyword arguments
12461242
#

control/sisotool.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,21 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
331331
u_summer = summing_junction(['ufb', 'uff', 'd'], 'u')
332332

333333
if isctime(plant):
334-
prop = tf(1, 1)
335-
integ = tf(1, [1, 0])
336-
deriv = tf([1, 0], [tau, 1])
334+
prop = tf(1, 1, inputs='e', outputs='prop_e')
335+
integ = tf(1, [1, 0], inputs='e', outputs='int_e')
336+
deriv = tf([1, 0], [tau, 1], inputs='y', outputs='deriv')
337337
else: # discrete-time
338-
prop = tf(1, 1, dt)
339-
integ = tf([dt/2, dt/2], [1, -1], dt)
340-
deriv = tf([1, -1], [dt, 0], dt)
338+
prop = tf(1, 1, dt, inputs='e', outputs='prop_e')
339+
integ = tf([dt/2, dt/2], [1, -1], dt, inputs='e', outputs='int_e')
340+
deriv = tf([1, -1], [dt, 0], dt, inputs='y', outputs='deriv')
341341

342-
# add signal names by turning into iosystems
343-
prop = tf2io(prop, inputs='e', outputs='prop_e')
344-
integ = tf2io(integ, inputs='e', outputs='int_e')
345342
if derivative_in_feedback_path:
346-
deriv = tf2io(-deriv, inputs='y', outputs='deriv')
347-
else:
348-
deriv = tf2io(deriv, inputs='e', outputs='deriv')
343+
deriv = -deriv
349344

350345
# create gain blocks
351-
Kpgain = tf2io(tf(Kp0, 1), inputs='prop_e', outputs='ufb')
352-
Kigain = tf2io(tf(Ki0, 1), inputs='int_e', outputs='ufb')
353-
Kdgain = tf2io(tf(Kd0, 1), inputs='deriv', outputs='ufb')
346+
Kpgain = tf(Kp0, 1, inputs='prop_e', outputs='ufb')
347+
Kigain = tf(Ki0, 1, inputs='int_e', outputs='ufb')
348+
Kdgain = tf(Kd0, 1, inputs='deriv', outputs='ufb')
354349

355350
# for the gain that is varied, replace gain block with a special block
356351
# that has an 'input' and an 'output' that creates loop transfer function

control/statefbk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ def create_statefbk_iosystem(
754754
" output must include the full state")
755755
elif estimator == sys:
756756
# Issue a warning if we can't verify state output
757-
if (isinstance(sys, NonlinearIOSystem) and sys.outfcn is not None) or \
757+
if (isinstance(sys, NonlinearIOSystem) and
758+
not isinstance(sys, StateSpace) and sys.outfcn is not None) or \
758759
(isinstance(sys, StateSpace) and
759760
not (np.all(sys.C[np.ix_(state_indices, state_indices)] ==
760761
np.eye(sys_nstates)) and

0 commit comments

Comments
 (0)