You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
Interpret str-type args to `interconnect` as non-sequence
roryyorke commentedon Jan 29, 2022
This is easy enough to fix (I hope!), see PR.
Two remarks: first, this description of the
inputsarg mentions an option of aninteger count, which I found difficult to understand, and which also doesn't seem to work:My test case:
Second,
InterconnectedSystemrefers one tointerconnectfor explanation of arguments, but while they're similar, I don't think they're identical; e.g., substitutingInterconnectedSystemforinterconnectin the example above doesn't work; one needs the actual system names (sys[0], etc.). I didn't look for other possible differences.Interpret str-type args to `interconnect` as non-sequence