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

Switch LTI class and subclasses to use ninputs, noutputs, nstates#515

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

@murrayrmmurrayrm commentedJan 20, 2021
edited
Loading

This PR changes theLTI class and theStateSpace class (and all derived classes) to useninputs,noutputs, andnstates as the attributes for storing these properties instead ofinputs,outputs, andstates. The former names are consistent with what is used in theInputOutputSystem class.

Following the suggestion of@bnavigator in issue#451, getter and setter functions are used for backward compatibility, but with aPendingDeprecationWarning.

Note that this PR will generate some small conflicts with#514. I'll rebase based on which one we merge first. [done]

@murrayrmmurrayrm added this to the0.9.0 milestoneJan 20, 2021
@coveralls
Copy link

coveralls commentedJan 20, 2021
edited
Loading

Coverage Status

Coverage decreased (-0.06%) to 87.553% when pullingeb401a9 on murrayrm:input_output_to_ninput_noutput into1502d38 on python-control:master.

@sawyerbfuller
Copy link
Contributor

Awesome! Looks good to me.

@sawyerbfuller
Copy link
Contributor

One more thing I noticed: there are a few mentions of sys.inputs/outputs in docs in xferfunc.py that should probably be fixed.

@murrayrmmurrayrmforce-pushed theinput_output_to_ninput_noutput branch from374c82f to5a4c3abCompareJanuary 21, 2021 00:53
@murrayrm
Copy link
MemberAuthor

Rebased against master (and apparently fixed up the xferfcn.py docstring, since I can't find sys.inputs in that file anymore).

@sawyerbfuller
Copy link
Contributor

sawyerbfuller commentedJan 21, 2021 via email
edited by murrayrm
Loading

May also need to check for self.inputs ?

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 more comment: was it a deliberate choice to leave init keywords as inputs/outputs rather than ninputs/noutputs, eg in lti.py:

definit(self, inputs=1, outputs=1, dt=None):

@murrayrmmurrayrmforce-pushed theinput_output_to_ninput_noutput branch fromd614c01 tof633874CompareJanuary 23, 2021 18:37
@murrayrm
Copy link
MemberAuthor

was it a deliberate choice to leave init keywords as inputs/outputs rather than ninputs/noutputs,

This matches the syntax we use in theInputOutputSystem class constructor. In that setting (and perhaps later here as well), inputs and outputs can be an integer or a list of strings (which get used for signal names).

@sawyerbfuller
Copy link
Contributor

That makes sense. Thanks!

Comment on lines 64 to 67
raise PendingDeprecationWarning(
"The LTI `inputs` attribute will be deprecated in a future "
"release. Use `ninputs` instead.")
return self.ninputs
Copy link
Contributor

Choose a reason for hiding this comment

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

This raises an Exception of the classPendingDeprecationWarning and never returns self.inputs.

Python 3.8.6 (default, Nov 09 2020, 12:09:06) [GCC] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import control>>> rsys = control.rss(3,3,3)>>> ninputs = rsys.inputsTraceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/ben/src/python-control/control/lti.py", line 64, in inputs    raise PendingDeprecationWarning(PendingDeprecationWarning: The LTI `inputs` attribute will be deprecated in a future release.  Use `ninputs` instead.>>> ninputsTraceback (most recent call last):  File "<stdin>", line 1, in <module>NameError: name 'ninputs' is not defined
Suggested change
raisePendingDeprecationWarning(
"The LTI `inputs` attribute will be deprecated in a future "
"release. Use `ninputs` instead.")
returnself.ninputs
warn("The LTI `inputs` attribute will be deprecated in a future "
"release. Use `ninputs` instead.",
PendingDeprecationWarning,stacklevel=2)
returnself.ninputs

Additionally, either a warning filter needs to be set in order to make the warning visible to end users, or a different category than*DeprecationWarning needs to be used.

filterwarnings('module',message=".*LTI.*attribute.*deprecated",category=PendingDeprecationWarning)
Python 3.8.6 (default, Nov 09 2020, 12:09:06) [GCC] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import control; rsys = control.rss(3,3,3); ninputs = rsys.inputs<stdin>:1: PendingDeprecationWarning: The LTI `inputs` attribute will be deprecated in a future release.  Use `ninputs` instead.>>> ninputs3
  • Please add a check using pytest.warns().

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I've fixed these up and decide to use DeprecationWarning for now (keep things internal to developers) but in a future release (0.9.x) we should change to FutureWarning, which will make it show up for users as well.

Copy link
Contributor

@bnavigatorbnavigatorJan 24, 2021
edited
Loading

Choose a reason for hiding this comment

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

Still using raise instead ofwarn. Now we are at:

This raises an Exception of the class DeprecationWarning and never returns self.inputs.

Python 3.8.6 (default, Nov 09 2020, 12:09:06) [GCC] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import control; rsys = control.rss(3,3,3); ninputs = rsys.inputsTraceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/ben/src/python-control/control/lti.py", line 64, in inputs    raise DeprecationWarning(DeprecationWarning: The LTI `inputs` attribute will be deprecated in a future release.  Use `ninputs` instead.>>> ninputsTraceback (most recent call last):  File "<stdin>", line 1, in <module>NameError: name 'ninputs' is not defined>>>

Comment on lines 254 to 255
with pytest.raises(DeprecationWarning, match="LTI `inputs`"):
assert sys.inputs == sys.ninputs
Copy link
Contributor

@bnavigatorbnavigatorJan 24, 2021
edited
Loading

Choose a reason for hiding this comment

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

The assert .. == part is never evaluated after sys.ninputs throws the exception.

Copy link
MemberAuthor

@murrayrmmurrayrmJan 24, 2021
edited
Loading

Choose a reason for hiding this comment

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

Sorry, was working on multiple changes/branches at once and pushed the wrong version. New one was what was intended.

@murrayrmmurrayrmforce-pushed theinput_output_to_ninput_noutput branch 2 times, most recently frombed8990 toff5fb39CompareJanuary 24, 2021 18:08
@murrayrmmurrayrmforce-pushed theinput_output_to_ninput_noutput branch fromff5fb39 toeb401a9CompareJanuary 24, 2021 18:10
@bnavigatorbnavigator merged commiteb146a6 intopython-control:masterJan 24, 2021
@murrayrmmurrayrm deleted the input_output_to_ninput_noutput branchJanuary 31, 2021 00:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sawyerbfullersawyerbfullersawyerbfuller left review comments

@bnavigatorbnavigatorbnavigator approved these changes

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

Successfully merging this pull request may close these issues.

4 participants
@murrayrm@coveralls@sawyerbfuller@bnavigator

[8]ページ先頭

©2009-2025 Movatter.jp