Skip to content

Add aliases of selected functions as member functions to LTI #1092

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

lkies
Copy link
Contributor

@lkies lkies commented Jan 7, 2025

And add automatic frequency computation to LTI.frequency_response since refactoring to replace it with control.frequency_response is not possible without breaking changes.

Closes #1084

@coveralls
Copy link

coveralls commented Jan 7, 2025

Coverage Status

coverage: 94.781% (-0.009%) from 94.79%
when pulling 566627b on lkies:main
into 93c4c8d on python-control:main.

Copy link
Member

@murrayrm murrayrm left a comment

Choose a reason for hiding this comment

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

Thanks for these contributions. These look OK to me.

I think we need to put in some sort of unit test just to make sure the functions work as intended. This is perhaps as simple as just creating a state space system (which has all of the member functions defined), making sure all of the member functions point to the existing function, and then calling it with no argument and with some simple argument(s) to make sure we get a ControlPlot back.

control/lti.py Outdated
Comment on lines 217 to 232
# conversions
to_ss: Callable
to_tf: Callable

# system interconnections
feedback: Callable

# freq domain plotting
bode_plot: Callable
nyquist_plot: Callable
nichols_plot: Callable

# time domain simulation
forced_response = control.timeresp.forced_response
impulse_response = control.timeresp.impulse_response
step_response = control.timeresp.step_response
Copy link
Member

Choose a reason for hiding this comment

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

We should add (short) docstrings for these. Since these are initialized as assigned member variables instead of standard function (using def), we will have to use the doc-comment format (lines starting with #: before the variable). See InputOutputSystem.nstates for an example.

I think these can be short, perhaps of the form: "Bode plot; see bode_plot function for more information".

@@ -244,6 +244,7 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
'append': test_unrecognized_kwargs,
'bode': test_response_plot_kwargs,
'bode_plot': test_response_plot_kwargs,
'LTI.bode_plot': test_response_plot_kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

I would add a comment at the end of this line (and the equivalent lines below) indicating that this is tested via bode_plot since there is not a separate test for the member function (and it really isn't needed, since it is the same object).

@lkies
Copy link
Contributor Author

lkies commented Jan 10, 2025

Hi,
i made the changes you suggested. I also noticed that feedback is already implemented on derived classes so I replaced the alias with a stub so that type checkers know they can call it on LTI objects.

@murrayrm murrayrm merged commit a1791c9 into python-control:main Jan 13, 2025
23 checks passed
@murrayrm murrayrm added this to the 0.10.2 milestone Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response Functions as Member Functions?
3 participants