GeezerVison is showing github.com — Interconnect treats string as list · Issue #692 · python-control/python-control
Interconnect treats string as list #692DescriptionIf you pass the interconnect function a string instead of a list, it treats the string as a list (of characters). For example:
P1 = ct.rss(2, 1, 1)
P1_iosys = ct.LinearIOSystem(P1, inputs='u1', outputs='y1')
P2 = ct.rss(2, 1, 1)
P2_iosys = ct.LinearIOSystem(P2, inputs='y1', outputs='y2')
P_series = ct.interconnect([P1_iosys, P2_iosys], inputs=['u1'], outputs=('y2'))
generates the following error:
ValueError: could not find signal y
The problem appears to be that ('y2') is the same as 'y2' in Python and is being interpreted as ['y', '2']. Changing this to outputs=('y2',) or outputs=['y2'] fixes the problem, but it is still a bug. Activityadded a commit that references this issue on Jan 29, 2022This issue will close once commit 37d3148 is merged into the 'master' branch.37d3148 roryyorke commented on Jan 29, 2022 This is easy enough to fix (I hope!), see PR.
Two remarks: first, this description of the inputs arg mentions an option of an integer count, which I found difficult to understand, and which also doesn't seem to work:
inputs : int, list of str or None, optional
Description of the system inputs. This can be given as an integer
count or as a list of strings that name the individual signals. If an
integer count is specified, the names of the signal will be of the
form `s[i]` (where `s` is one of `u`, `y`, or `x`). If this parameter
is not given or given as `None`, the relevant quantity will be
determined when possible based on other information provided to
functions using the system.
My test case:
In [26]: P1 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='u1', outputs='y1')
...: P2 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='y1', outputs='y2')
...: ct.interconnect([P1, P2], inputs=1)
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-26-ca5ff6a9552e> in <module>
1 P1 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='u1', outputs='y1')
2 P2 = ct.LinearIOSystem(ct.rss(2,1,1), inputs='y1', outputs='y2')
----> 3 ct.interconnect([P1, P2], inputs=1)
~/src/python-control/control/iosys.py in interconnect(syslist, connections, inplist, outlist, inputs, outputs, states, params, dt, name, check_unused, ignore_inputs, ignore_outputs, **kwargs)
2530 if not outlist and outputs is not None:
2531 outlist = list(outputs)
-> 2532
2533 # Process input list
2534 if not isinstance(inplist, (list, tuple)):
TypeError: 'int' object is not iterable
Second, InterconnectedSystem refers one to interconnect for explanation of arguments, but while they're similar, I don't think they're identical; e.g., substituting InterconnectedSystem for interconnect in the example above doesn't work; one needs the actual system names (sys[0], etc.). I didn't look for other possible differences. added a commit that references this issue on Mar 18, 2022This issue will close once commit fdd2ecb is merged into the 'main' branch.fdd2ecb
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|