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

Using a class method in a NonlinearIOSystem#630

Answeredbydkunz49
dkunz49 asked this question inQ&A
Discussion options

I am trying to use a class method in a NonlinearIOSystem. To test, I adapted the predator-prey example such that the predprey_rhs function becomes a method in the new predprey class. Then, I create an instance of the predprey class (pp), and create the NonlinearIOSystem using the pp.predprey_rhs method. All good to that point. When I try to calculate the open-loop response with control.input_output_response, I get "TypeError: dynamics() takes 4 positional arguments but 5 were given". The method predprey_rhs has the self argument in its definition, so that shouldn't be a problem. Anyone have any ideas?

You must be logged in to vote

I figured it out. Apparently, "params" is required as an argument for the predprey_rhs method. Previously, I defined the parameters ininit, and didn't include "params" as a predprey_rhs method. Once I added it back in, even though is wasn't used, the error went away. I still don't understand why it threw the TypeError, but no matter.

Replies: 1 comment 2 replies

Comment options

I figured it out. Apparently, "params" is required as an argument for the predprey_rhs method. Previously, I defined the parameters ininit, and didn't include "params" as a predprey_rhs method. Once I added it back in, even though is wasn't used, the error went away. I still don't understand why it threw the TypeError, but no matter.

You must be logged in to vote
2 replies
@bnavigator
Comment options

"param is an optional dict" in the doc for updfnc is a bit misleading, I think. There is code relying on the presence of the parameter, even if it not used.

@murrayrm
Comment options

Fixed in PR#633.

Answer selected bybnavigator
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@dkunz49@murrayrm@bnavigator
Converted from issue

This discussion was converted from issue #629 on June 10, 2021 19:31.


[8]ページ先頭

©2009-2025 Movatter.jp