- Notifications
You must be signed in to change notification settings - Fork441
I/O system enhancements#1082
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
coveralls commentedDec 20, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
8888c03
toe4d373c
CompareI will finish reviewing this tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I made several comments about misprints. Code appears to be correct. I am going to examine it a bit more in the morning.
control/tests/docstrings_test.py Outdated
# | ||
# List of arguments described in class docstrings | ||
# | ||
# These are the minimal arguments needed to initialized the class. Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
# These are the minimal arguments needed toinitialized the class. Optional | |
# These are the minimal arguments needed toinitialize the class. Optional |
control/tests/docstrings_test.py Outdated
# List of attributes described in class docstrings | ||
# | ||
# This is the list of attributes for the class that are not already listed | ||
# as parameters used to inialize the class. These should all be defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
# as parameters used toinialize the class. These should all be defined | |
# as parameters used toinitialize the class. These should all be defined |
control/frdata.py Outdated
frequency : 1D array | ||
Array of frequency points for which data are available. | ||
ninputs, noutputs : int | ||
Number of inputs and outputs signals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Numberofinputsandoutputssignals. | |
Numberofinputandoutputsignals. |
which is consistent with usage below (description ofinput_labels, output_labels
), or could be "Number of inputs and outputs."
control/frdata.py Outdated
magnitude : array | ||
Magnitude of the frequency response, indexed by frequency. | ||
phase : array | ||
Magnitude of the frequency response, indexed by frequency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Magnitudeofthefrequencyresponse,indexedbyfrequency. | |
Phaseofthefrequencyresponse,indexedbyfrequency. |
control/xferfcn.py Outdated
Notes | ||
----- | ||
The attribues 'num' and 'den' are 2-D lists of arrays containing MIMO | ||
numerator and denominator coefficients. For example, | ||
The numerator and denominator polynomials are stored as 2D ndarray's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thenumeratoranddenominatorpolynomialsarestoredas2Dndarray's | |
Thenumeratoranddenominatorpolynomialsarestoredas2Dndarrays |
Style used in the NumPy documentation is "ndarrays" (no apostrophe); e.g., inhttps://numpy.org/doc/stable/user/basics.indexing.html andhttps://numpy.org/doc/stable/user/basics.creation.html.
control/statesp.py Outdated
# | ||
# Author: Richard M. Murray | ||
# Date: 24 May 09 | ||
# Revised: Kevin K. Chen, Dec 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Outside the scope of this PR, but eventually we should consider removing comments with author names like this or add a note that
- these dates are from before moving to Git for version control
- and the up-to-date authorship is available in commit history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I took a cut at this in the commit that is coming next. See what you think and we can fix things up globally (I have another PR in the works where I could do that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like your proposed change: it is concise and shows a simple command to get the list of authors.
control/xferfcn.py Outdated
to prettier LaTeX representation """ | ||
"""Superscript all digits in a polynomial string and convert float | ||
coefficients in scientific notation to prettier LaTeX | ||
representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Docstring alignment is odd for this function.
control/iosys.py Outdated
repr_format : str | ||
String representation format ('iosys' or 'loadable'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is there arepr_format
attribute, or is this referring to__repr__
? If the latter, I find it confusing to write "repr_format" in this list because it is not the name of an attribute. Also, note that__repr__
is astandard method described in the Python documentation, so probably OK to not document it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think this crept through from a separate PR that I am working on (and will show up next). Will delete from here (and one other spot where it shows up).
control/tests/xferfcn_test.py Outdated
# 13 Dec 2024: This now works correctly: creates static array (as tf) | ||
# with pytest.raises(TypeError): | ||
# TransferFunction([[0., 1.], [2., 3.]], [[5., 2.], [3., 0.]]) | ||
# good input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I recommend deleting this comment block (from "13 Dec..." to "good input"). The fact that this was previously tested as a known error is already recorded in commit history. If the goal with this comment is to notify users about the behavior change, then probably it will be easier to find in the next release announcement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'll remove this test completely, since it is now longer a "bad input type" (from the name of the test method).
forarr in[num,den]: | ||
for poly innp.nditer(arr, flags=['refs_ok']): | ||
if poly.item().size > 1: | ||
static = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
forarrin [num,den]: | |
forpolyinnp.nditer(arr,flags=['refs_ok']): | |
ifpoly.item().size>1: | |
static=False | |
forarrin [num,den]: | |
ifnotstatic: | |
break | |
forpolyinnp.nditer(arr,flags=['refs_ok']): | |
ifpoly.item().size>1: | |
static=False | |
break |
This is a small optimization: I noticed that afterstatic = False
is reached, the outer and inner loops can be exited immediately. For example, the system in the PR description:
s = ct.tf('s')sys = ct.tf([[1/s, 0], [(s+1)/(s**2 + 2*s + 1), 1/(s+1)]])
results in several cases of needlessly reachingstatic = False
more than once. However, I did not rigorously quantify the potential benefit, so OK to not do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Update coming in a bit to address these.
@slivingston Are you still reviewing, or is it OK to merge? (I have two more PR's coming that build on this one.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@murrayrm Sorry for the delay. I am still reviewing but will be done in 30 minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@murrayrm done now. There are 2 misprints and 1 bug. After handling these, ready to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Great PR. Just came here to note that there is already an_isstatic
method that is also short-circuiting. Can we use the same code for both - perhaps by moving the code to a separate function that tests num and den, and a method that calls it?
control/nlsys.py Outdated
lambda t, x, u, params: sys.A @ x + sys.B @ u, | ||
lambda t, x, u, params: sys.C @ x + sys.D @ u, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
lambdat,x,u,params:sys.A @x+sys.B @u, | |
lambdat,x,u,params:sys.C @x+sys.D @u,**kwargs) | |
lambdat,x,u,params:sys_ss.A @x+sys_ss.B @u, | |
lambdat,x,u,params:sys_ss.C @x+sys_ss.D @u,**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is a bug and needs to be fixed before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Good catch on this. In the latest update, I added a unit test that catches the bug (and fixed the bug).
control/statefbk.py Outdated
@@ -751,6 +752,10 @@ def create_statefbk_iosystem( | |||
System name. If unspecified, a generic name <sys[id]> is generated | |||
with a unique integer id. | |||
params : dict, optional | |||
System parameter values. By default, these will be copied from | |||
`sys` and `ctrl`, but can be overriden with this keyword. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
`sys`and`ctrl`,butcanbeoverridenwiththiskeyword. | |
`sys`and`ctrl`,butcanbeoverriddenwiththiskeyword. |
control/statesp.py Outdated
``ss(args, inputs=['u1', ..., 'up'], outputs=['y1', ..., 'yq'], states=['x1', ..., 'xn'])`` | ||
``ss(*args, inputs=['u1', ..., 'up'], outputs=['y1', ..., 'yq'], | ||
states=['x1', ..., 'xn'])`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Splitting this in-line code expression across 2 lines breaks Sphinx processing, resulting in
Compare with the rendering ofss(A, B, C, D, dt)
in the above image and the rendering of these in the current docs athttps://python-control.readthedocs.io/en/0.10.1/generated/control.ss.html
forarr in[num,den]: | ||
for poly innp.nditer(arr, flags=['refs_ok']): | ||
if poly.item().size > 1: | ||
static = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@murrayrm Sorry for the delay. I am still reviewing but will be done in 30 minutes.
93c4c8d
intopython-control:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This PR provides a number of enhancements to I/O systems classes, most of which are internal but a few of which are visible to the user:
tf()
factory function to allow a 2D list of SISO transfer functions to be given as a means of creating a MIMO transfer function (use the newcombine_tf
function). This is redundant withcombine_tf
, but seemed useful to include in the factory function for the special case of creating a MIMO transfer function via a set of SISO expressions. E.g.:params
keyword tocreate_statefbk_iosystem
.interconnect()
to combine parameter lists of subsystems ifparams
is not specified.FrequencyResponseData._ifunc
, which is the internally generated interpolation function if thesmooth
keyword is used).sys.num_array[i, j]
instead ofsys.num_list[i][j]
). The nested list representation is still available via the{num,den}_list
properties and thenum
andden
attributes retrieve the nested list structure for backward compatibility. (We may want to change that in the future, but it could break user code where someone is accessing the numerator and denominator polynomials directly.)nlsys
to create aNonlinearIOSystem
representation of aStateSpace
system. It's not clear that this is so useful for a user (sinceStateSpace
is a subclass ofNonlinearIOSystem
), but it is handy for testing since you can quickly create a nonlinear I/O system from a linear system but have it treated as a "pure"NonlinearIOSystem
instead of aStateSpace
system.LICENSE
file in the main directory).Note: this PR is likely to conflict with#1081, so the plan is to review/merge#1081 first, then rebase this PR on top of that one.