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 — Fixed InterconnectedSystems name bugs. by samlaf · Pull Request #400 · python-control/python-control

Conversation

@samlaf

@samlaf samlaf commented May 14, 2020

Copy link
Copy Markdown
Contributor

3 fixes to InterconnectedSystem's init:

  1. It wasn't setting the name properly
  2. It also wasn't setting the output and input names properly
  3. I also made it so that instead of using generic state names, it uses subsys.statename when available

For example, if we Interconnected these two systems

System: predprey
Inputs (1): u, 
Outputs (2): H, L, 
States (2): H, L, 

System: control
Inputs (3): Ld, u1, u2, 
Outputs (1): y[0], 
States (0):

we would get

System: (None)               # point (1)
Inputs (0): 
Outputs (3):                 # point (2)
States (2): x[0], x[1],      # point (3)

Now instead, we get

System: io_closed
Inputs (0): 
Outputs (3): y[0], y[1], y[2], 
States (2): predpreyH, predpreyL, 

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@samlaf
Made sure interconnectedsystems keeps names of parts.
672f229
bnavigator
bnavigator requested changes May 17, 2020
View reviewed changes
Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@samlaf @bnavigator
Update control/iosys.py
15a442a
Co-authored-by: Ben Greiner <[email protected]>
bnavigator
bnavigator reviewed May 18, 2020
View reviewed changes
Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

samlaf and others added 3 commits May 18, 2020 11:48
@samlaf @bnavigator
Update control/iosys.py
77f9441
Co-authored-by: Ben Greiner <[email protected]>
@samlaf
Fixed signal names for InterconnectedSystems.
d45a6c0
Only the outlist specification I am not sure.
First, why can subsystem inputs be connected to system outputs?
Then, why was the specification and code in __init__ different from that
for the inplist?
I changed it to match inplist, but left the weird subsystem input configuration.
Check comment that starts with "Convert the output list to a matrix".
@samlaf
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
b688729
…hon-control into interconnectedsystems
@coveralls

coveralls commented May 20, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 84.044% when pulling b2c8d44 on samlaf:interconnectedsystems into d3142ff on python-control:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented May 20, 2020

Copy link
Copy Markdown
Contributor Author

Here's a short code snippet to visualize the signal names for different Connections:

import control

nlios111 = control.NonlinearIOSystem(
    lambda t,x,u,params: x, inputs=2, outputs=2, states=2
)
nlios101 = control.NonlinearIOSystem(
    None, lambda t,x,u,params: u, inputs=2, outputs=2
)

series = nlios111 * nlios101
parallel = nlios111 + nlios101
neg = - nlios111
feedback = nlios101.feedback(nlios111)
dup = nlios111 * nlios111.copy() #if we remove the .copy() we get a warning and names are messed up
hierarchical = series*nlios111

print("1 input, 1 state, 1 output:\n", nlios111, "\n")
print("1 input, no state, 1 output:\n", nlios101, "\n")
print("Series connection: sys[0] * sys[1]\n", series, "\n")
print("Parallel connection: sys[0] + sys[1]\n", parallel, "\n")
print("Negative connection: -sys[0]\n", neg, "\n")
print("Feedback connection: sys[1].feedback(sys[0])\n", feedback, "\n")
print("Connection with duplicate systems: sys[0] * sys[0].copy()\n", dup, "\n")
print("Hierarchical connection: series * sys[0]\n", hierarchical)

And the output after my last push:

1 input, 1 state, 1 output:
System: sys[0]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (2): x[0], x[1],

1 input, no state, 1 output:
System: sys[1]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (0):

Series connection: sys[0] * sys[1]
System: sys[2]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (2): sys[0].x[0], sys[0].x[1],

Parallel connection: sys[0] + sys[1]
System: sys[3]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (2): sys[0].x[0], sys[0].x[1],

Negative connection: -sys[0]
System: sys[4]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (2): sys[0].x[0], sys[0].x[1],

Feedback connection: sys[1].feedback(sys[0])
System: sys[5]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (2): sys[0].x[0], sys[0].x[1],

Connection with duplicate systems: sys[0] * sys[0].copy()
System: sys[7]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (4): sys[6].x[0], sys[6].x[1], sys[0].x[0], sys[0].x[1],

Hierarchical connection: series * sys[0]
System: sys[8]
Inputs (2): u[0], u[1],
Outputs (2): y[0], y[1],
States (4): sys[0].x[0], sys[0].x[1], sys[2].sys[0].x[0], sys[2].sys[0].x[1],

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm

murrayrm commented Jul 11, 2020

Copy link
Copy Markdown
Member

@samlaf Can you add some unit tests to cover your new code and show that things are working? The examples that you have in your comment from 20 May would probably be fine. You might also try mixing named systems and named signals with unnamed systems/signals to make sure that nothing funny happens. And, as a harder test, try creating a system/signal with a name that would conflict with the default name (eg, create a system whose name is sys[1] and combine it with an unnamed systems).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator reviewed Jul 15, 2020
View reviewed changes
Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented Jul 15, 2020

Copy link
Copy Markdown
Contributor Author

@samlaf Can you add some unit tests to cover your new code and show that things are working? The examples that you have in your comment from 20 May would probably be fine. You might also try mixing named systems and named signals with unnamed systems/signals to make sure that nothing funny happens. And, as a harder test, try creating a system/signal with a name that would conflict with the default name (eg, create a system whose name is sys[1] and combine it with an unnamed systems).

Should I be enforcing sys/signals names here? Wouldn't this render the API a bit too rigid (in case people want to change the naming conventions later, etc.)
Otherwise, what kind of unit tests did you have in mind?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

samlaf
samlaf commented Jul 15, 2020
View reviewed changes
Comment thread control/iosys.py
states = []
for sys in sysobj_list:
states += [sys.name + '.' + statename for statename in sys.state_index.keys()]

@samlaf samlaf Jul 15, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@murrayrm This is the part that would break if you add a named signal with a generic 'sys[i]' that will cause a conflict (it's no different from having two systems with the same name). The only "bad" thing that happens is that the system will be missing the state names of the systems with conflicting names (only the first 'sys[i].states' will be present).
Right now we are only raising a warning. As I mention in the comment, users can use sys.copy() first to create a unique name. Is this ok?

Edit: see the comment above this snippet of code... I'm new to this and not sure how to include it in the comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
samlaf and others added 2 commits July 15, 2020 15:34
@samlaf @bnavigator
Update control/iosys.py
c8fba97
Co-authored-by: Ben Greiner <[email protected]>
@samlaf @bnavigator
Update control/iosys.py
bd38dea
Co-authored-by: Ben Greiner <[email protected]>
bnavigator
bnavigator reviewed Jul 15, 2020
View reviewed changes
Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

samlaf added 2 commits July 15, 2020 20:51
@samlaf
Fixed some naming convention problems and added unit tests for naming…
35676f2
… conventions.
@samlaf
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
90705d4
…hon-control into interconnectedsystems
bnavigator
bnavigator reviewed Jul 16, 2020
View reviewed changes
Comment thread control/tests/iosys_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/tests/iosys_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/tests/iosys_test.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread control/iosys.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm

murrayrm commented Jul 18, 2020

Copy link
Copy Markdown
Member

Unit tests are failing because

nlsys * nlsys

no longer works. It seems like it should be possible to take two copies of a system and put them in series (which is what this does) without generating an error.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

samlaf and others added 5 commits July 19, 2020 14:40
@samlaf
Removed for loops from tests to get better error messages
69cc8c5
@samlaf @bnavigator
Update control/iosys.py
e76a4f8
Co-authored-by: Ben Greiner <[email protected]>
@samlaf
Changed a lot of naming convention code/unit test following pull-requ…
abb1f19
…est conversation.
@samlaf
Merge branch 'interconnectedsystems' of https://github.com/samlaf/pyt…
f955b3a
…hon-control into interconnectedsystems
@samlaf
Fixed system naming conventions and unit tests. Still need to do sign…
3ec2f02
…al names.
@samlaf

samlaf commented Jul 19, 2020

Copy link
Copy Markdown
Contributor Author

Thank you for pointing this out @murrayrm, and thanks a lot to both of you two for your patience... newbie at work here.
I was concentrating on the signal_names test for too long and forget to rerun the other tests afterwards. Should be fixed now.

The system naming convention code should be fine now. Still need to write the signal name convention unit test though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm

murrayrm commented Jul 19, 2020

Copy link
Copy Markdown
Member

Looks like git got confused by the new unit test. I don't see any actual conflicts, but you may need to fiddle with things to allow the automatic merge check to work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented Jul 20, 2020

Copy link
Copy Markdown
Contributor Author

It seems like a conflict between my branch and master branch?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm

murrayrm commented Jul 20, 2020

Copy link
Copy Markdown
Member

That's what it's saying, but what's odd is that I don't see the conflict. You added in a test and it shouldn't conflict with other tests. If you agree, I can try to fix it via the web interface and we'll see if that gets things running again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented Jul 20, 2020

Copy link
Copy Markdown
Contributor Author

Sure, please do. I wouldn't know what to try anyways and would be scared to break other things.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

murrayrm and others added 2 commits July 19, 2020 19:50
@murrayrm
Merge branch 'master' into interconnectedsystems
8c957b2
@samlaf
Finished test_signals_naming_convention unit test
b2c8d44
@samlaf

samlaf commented Jul 22, 2020

Copy link
Copy Markdown
Contributor Author

I added the last unit tests. This is ready to be reviewed and hopefully should be close to done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 23, 2020
Mergetest Prs #400 #431 #433 bnavigator/python-control#1
Closed
Refactor the test suite using pytest for array and matrix types #438
Merged
@bnavigator

bnavigator commented Aug 1, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The changes remove test coverage of the functions set_input_map() and set_output_map()
https://coveralls.io/builds/32204258/source?filename=control%2Fiosys.py#L1284

In fact, those functions are not used by the whole package anymore. But they are public API. So a unit test for them should be present. (I would personally prefer that they are created in the style of #438. Feel free to add them as a PR against the bnavigator:array-matrix-tests branch)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented Aug 4, 2020

Copy link
Copy Markdown
Contributor Author

Sure I can do that.
Just to make sure I understand, I think these functions were used in the add, mul, etc. functions which interconnect systems. Before they would create a blank interconnected system and then use the setters like set_input_map to populate the object. I changed it so that the "setting" was done in the init code.
Anyways, my question is: this code being "covered" before means that the unit test was calling them? So even if there wasn't a designed unit test for these specific functions, at least if they had caused a bug that would have caused some unit test to fail, but now that's not the case anymore, so we should add an explicit unit test. Is this correct?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnavigator

bnavigator commented Aug 4, 2020

Copy link
Copy Markdown
Contributor

Yes, that is correct. The unit tests should make sure that using those functions results in the documented behavior. Previously, this was more or less implicit by the tests when __add__ , __mul__. __neg__ and feedback were called.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnavigator bnavigator mentioned this pull request Aug 19, 2020
Release 0.8.4 and 0.9.0 sequencing #451
Closed
bnavigator added a commit to bnavigator/python-control that referenced this pull request Aug 20, 2020
@bnavigator
make iosys_test.py compatible with current source code state
0a01f30
revert this commit when merging into or with python-control#400 and python-control#431
bnavigator added a commit to bnavigator/python-control that referenced this pull request Aug 20, 2020
@bnavigator
make iosys_test.py compatible with current source code state
f0fcc08
revert this commit when merging into or with python-control#400 and python-control#431
@bnavigator

bnavigator commented Aug 20, 2020

Copy link
Copy Markdown
Contributor

Hi @samlaf, if you still intend to update your PR with the requested unit tests, please do so based on the iosys_test.py in #438. We are discussing in #451 about the proper merge sequence, and #438 will likely be the first.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@samlaf

samlaf commented Aug 20, 2020

Copy link
Copy Markdown
Contributor Author

Hi @bnavigator, I was planning on doing these, but I got major neck pain recently, and am spending some time away from the keyboard. Are you waiting on me to merge the other PRs? I'm not sure when I'll have time to write these, but if it's not a hurry I will eventually get to them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnavigator

bnavigator commented Aug 20, 2020

Copy link
Copy Markdown
Contributor

No hurry, get well soon! As I wrote, I removed the dependency in my PR so your PR can be merged later. Whenever you can get to it. You will have to rebase.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnavigator
bnavigator approved these changes Oct 15, 2020
View reviewed changes
@bnavigator bnavigator added this to the 0.8.4 milestone Oct 15, 2020
@murrayrm
murrayrm merged commit 98ec00f into python-control:master Oct 17, 2020
bnavigator added a commit to bnavigator/python-control that referenced this pull request Dec 29, 2020
@bnavigator
make iosys_test.py compatible with current source code state
2082796
revert this commit when merging into or with python-control#400 and python-control#431
bnavigator added a commit to bnavigator/python-control that referenced this pull request Dec 29, 2020
@bnavigator
make iosys_test.py compatible with current source code state
efcd483
revert this commit when merging into or with python-control#400 and python-control#431
bnavigator added a commit to bnavigator/python-control that referenced this pull request Dec 29, 2020
@bnavigator
make iosys_test.py compatible with current source code state
fdf64ca
revert this commit when merging into or with python-control#400 and python-control#431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@murrayrm murrayrm murrayrm left review comments
@bnavigator bnavigator bnavigator approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

0.8.4

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@samlaf @coveralls @murrayrm @bnavigator
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.