Fix interconnect type conversion bug for StateSpace systems#788
Merged
sawyerbfuller merged 5 commits intopython-control:mainfrom Nov 16, 2022
Merged
Conversation
roryyorke
reviewed
Nov 13, 2022
Contributor
roryyorke
left a comment
There was a problem hiding this comment.
LGTM, except for the one comment.
control/iosys.py
Outdated
| type(self)) | ||
|
|
||
| def dynamics(self, t, x, u): | ||
| def dynamics(self, t, x, u, params={}): |
Contributor
There was a problem hiding this comment.
Is there a reason not to use the params=None, if params is None: params={} pattern here? Using mutable objects for default parameters is usually not a good idea.
Also, why not **kwargs?
control/iosys.py
Outdated
| returns the time derivative | ||
|
|
||
| dx/dt = f(t, x, u) | ||
| dx/dt = f(t, x, u, params) |
Contributor
There was a problem hiding this comment.
Suggested change
| dx/dt = f(t, x, u, params) | |
| dx/dt = f(t, x, u[, params]) |
control/iosys.py
Outdated
| If the system is discrete-time, returns the next value of `x`: | ||
|
|
||
| x[t+dt] = f(t, x[t], u[t]) | ||
| x[t+dt] = f(t, x[t], u[t], params) |
Contributor
There was a problem hiding this comment.
Suggested change
| x[t+dt] = f(t, x[t], u[t], params) | |
| x[t+dt] = f(t, x[t], u[t][, params]) |
Contributor
sawyerbfuller
left a comment
There was a problem hiding this comment.
One other thought: currently, StateSpace.dynamics does not have params as a kwarg, but it probably should (maybe with a warning that it will be ignored).
Contributor
|
Like the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes a problem that was identified in PR #785, where interconnecting a
LinearIOSystemwith aStateSpacesystem via theinterconnectfunction did not work correctly. In particular, if you created a mixed system of this type you would get back anInterconnectedSystemthat would generate an error is you tried to simulate it or evaluate the dynamics. This was fixed by adding a few lines of code tointerconnect()that convertStateSpaceandTransferFunctionobjects toLinearIOSystems, mimicking what is done with operator overloading.In addition, there was a bug where the
paramkeyword was not allowed in thedynamicsandoutputfunctions. This is now fixed and tested with a unit test.