GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Interconnect treats string as list · Issue #692 · python-control/python-control

Interconnect treats string as list #692

New issue
Copy link
New issue
Copy link
Closed
#698
Closed
Interconnect treats string as list#692
#698
Copy link

Description

@murrayrm
murrayrm
opened on Jan 19, 2022
Issue body actions

If 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.

Activity

  1. roryyorke
    added a commit that references this issue on Jan 29, 2022

    Interpret str-type args to `interconnect` as non-sequence

    This issue will close once commit 37d3148 is merged into the 'master' branch.
    37d3148
  2. roryyorke commented on Jan 29, 2022

    @roryyorke
    roryyorke
    on Jan 29, 2022
    Contributor
    More actions

    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.

  3. murrayrm
    closed this as completedin #698on Jan 30, 2022
  4. murrayrm
    added a commit that references this issue on Mar 18, 2022

    Interpret str-type args to `interconnect` as non-sequence

    This issue will close once commit fdd2ecb is merged into the 'main' branch.
    fdd2ecb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.