Repository navigation
Interconnect treats string as list #692
Copy link
Copy link
Closed
Description
Activity
- added a commit that references this issue
on 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: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 iterableSecond,
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.- added a commit that references this issue
on Mar 18, 2022
Metadata
Metadata
Assignees
Labels
No labels
If you pass the
interconnectfunction a string instead of a list, it treats the string as a list (of characters). For example:generates the following error:
The problem appears to be that
('y2')is the same as'y2'in Python and is being interpreted as['y', '2']. Changing this tooutputs=('y2',)oroutputs=['y2']fixes the problem, but it is still a bug.