Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eff6c40

Browse files
committed
updates to address @slivingston review comments
1 parent 412ef97 commit eff6c40

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

control/modelsimp.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def model_reduction(
8989
eliminated or those to be kept.
9090
9191
Two methods of state reduction are possible: 'truncate' removes the
92-
states marked for elimination, while 'matchdc' replaces the the
93-
eliminated states with their equilibrium values (thereby keeping the
94-
input/output gain unchanged at zero frequency ["DC"]).
92+
states marked for elimination, while 'matchdc' replaces the eliminated
93+
states with their equilibrium values (thereby keeping the input/output
94+
gain unchanged at zero frequency ["DC"]).
9595
9696
Parameters
9797
----------
@@ -104,9 +104,8 @@ def model_reduction(
104104
Vector of inputs, outputs, or states to keep. Can be specified
105105
either as an offset into the appropriate vector or as a signal name.
106106
method : string
107-
Method of removing states in `elim`: either 'truncate' or
108-
'matchdc' (default).
109-
warn_unstable: bool, option
107+
Method of removing states: either 'truncate' or 'matchdc' (default).
108+
warn_unstable : bool, option
110109
If `False`, don't warn if system is unstable.
111110
112111
Returns
@@ -136,23 +135,23 @@ def model_reduction(
136135
See Also
137136
--------
138137
balanced_reduction : Eliminate states using Hankel singular values.
139-
minimal_realization : Eliminate unreachable or unobseravble states.
138+
minimal_realization : Eliminate unreachable or unobservable states.
140139
141140
Notes
142141
-----
143142
The model_reduction function issues a warning if the system has
144-
unstable eigenvalues, since in those situations the stability reduced
145-
order model may be different that the stability of the full model. No
146-
other checking is done, so users to be careful not to render a system
147-
unobservable or unreachable.
143+
unstable eigenvalues, since in those situations the stability of the
144+
reduced order model may be different than the stability of the full
145+
model. No other checking is done, so users must to be careful not to
146+
render a system unobservable or unreachable.
148147
149-
States, inputs, and outputs can be specified using integer offers or
148+
States, inputs, and outputs can be specified using integer offsets or
150149
using signal names. Slices can also be specified, but must use the
151150
Python ``slice()`` function.
152151
153152
"""
154153
if not isinstance(sys, StateSpace):
155-
raise TypeError("system must be a a StateSpace system")
154+
raise TypeError("system must be a StateSpace system")
156155

157156
# Check system is stable
158157
if warn_unstable:
@@ -161,7 +160,7 @@ def model_reduction(
161160
warnings.warn("System is unstable; reduction may be meaningless")
162161

163162
# Utility function to process keep/elim keywords
164-
def _process_elim_or_keep(elim, keep, labels, allow_both=False):
163+
def _process_elim_or_keep(elim, keep, labels):
165164
def _expand_key(key):
166165
if key is None:
167166
return []
@@ -178,9 +177,8 @@ def _expand_key(key):
178177
keep = np.atleast_1d(_expand_key(keep))
179178

180179
if len(elim) > 0 and len(keep) > 0:
181-
if not allow_both:
182-
raise ValueError(
183-
"can't provide both 'keep' and 'elim' for same variables")
180+
raise ValueError(
181+
"can't provide both 'keep' and 'elim' for same variables")
184182
elif len(keep) > 0:
185183
keep = np.sort(keep).tolist()
186184
elim = [i for i in range(len(labels)) if i not in keep]

control/tests/modelsimp_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def testBalredMatchDC(self):
485485
({'elim_inputs': [0, 1, 2]}, 5, 3, 0), # no inputs
486486
({'elim_outputs': [0, 1, 2]}, 5, 0, 3), # no outputs
487487
({'elim_states': [0, 1, 2, 3, 4]}, 0, 3, 3), # no states
488-
({'elim_states': [0, 1], 'keep_states': [1, 2]}, None, None, None)
488+
({'elim_states': [0, 1], 'keep_states': [1, 2]}, None, None, None),
489489
])
490490
@pytest.mark.parametrize("method", ['truncate', 'matchdc'])
491491
def test_model_reduction(method, kwargs, nstates, noutputs, ninputs):

0 commit comments

Comments
 (0)