Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix interconnect type conversion bug for StateSpace systems#788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

murrayrm
Copy link
Member

This PR fixes a problem that was identified in PR#785, where interconnecting aLinearIOSystem with aStateSpace system via theinterconnect function did not work correctly. In particular, if you created a mixed system of this type you would get back anInterconnectedSystem that 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 convertStateSpace andTransferFunction objects toLinearIOSystems, mimicking what is done with operator overloading.

In addition, there was a bug where theparam keyword was not allowed in thedynamics andoutput functions. This is now fixed and tested with a unit test.

@murrayrmmurrayrm changed the titleInterconnect type conversion 12 nov2022Fix interconnect type conversion bug for StateSpace systemsNov 13, 2022
@coveralls
Copy link

coveralls commentedNov 13, 2022
edited
Loading

Coverage Status

Coverage increased (+0.04%) to 94.801% when pullinga9a6226 on murrayrm:interconnect_type_conversion-12Nov2022 intobeb629b on python-control:main.

Copy link
Contributor

@roryyorkeroryyorke left a comment

Choose a reason for hiding this comment

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

LGTM, except for the one comment.

@@ -369,23 +369,24 @@ def _rhs(self, t, x, u, params={}):
NotImplemented("Evaluation not implemented for system of type ",
type(self))

def dynamics(self, t, x, u):
def dynamics(self, t, x, u, params={}):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason not to use theparams=None,if params is None: params={} pattern here? Using mutable objects for default parameters is usually not a good idea.

Also, why not **kwargs?

"""Compute the dynamics of a differential or difference equation.

Given time `t`, input `u` and state `x`, returns the value of the
right hand side of the dynamical system. If the system is continuous,
returns the time derivative

dx/dt = f(t, x, u)
dx/dt = f(t, x, u, params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
dx/dt=f(t,x,u,params)
dx/dt=f(t,x,u[,params])


where `f` is the system's (possibly nonlinear) dynamics function.
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
x[t+dt]=f(t,x[t],u[t],params)
x[t+dt]=f(t,x[t],u[t][,params])

Copy link
Contributor

@sawyerbfullersawyerbfuller left a comment

Choose a reason for hiding this comment

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

One other thought: currently,StateSpace.dynamics does not haveparams as a kwarg, but it probably should (maybe with a warning that it will be ignored).

@roryyorke
Copy link
Contributor

Like thefor x in sequence or []: pattern. LGTM.

@sawyerbfullersawyerbfuller merged commitb32e355 intopython-control:mainNov 16, 2022
@murrayrmmurrayrm added this to the0.9.3 milestoneDec 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@roryyorkeroryyorkeroryyorke left review comments

@sawyerbfullersawyerbfullersawyerbfuller left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.9.3
Development

Successfully merging this pull request may close these issues.

4 participants
@murrayrm@coveralls@roryyorke@sawyerbfuller

[8]ページ先頭

©2009-2025 Movatter.jp