Skip to content

Commit 8aa271d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into gh-774
2 parents c1f1868 + f758725 commit 8aa271d

File tree

6 files changed

+78
-85
lines changed

6 files changed

+78
-85
lines changed

control/iosys.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ def ss(*args, **kwargs):
22422242
Convert a linear system into space system form. Always creates a
22432243
new system, even if sys is already a state space system.
22442244
2245-
``ss(updfcn, outfucn)```
2245+
``ss(updfcn, outfucn)``
22462246
Create a nonlinear input/output system with update function ``updfcn``
22472247
and output function ``outfcn``. See :class:`NonlinearIOSystem` for
22482248
more information.
@@ -2269,8 +2269,7 @@ def ss(*args, **kwargs):
22692269
Everything that the constructor of :class:`numpy.matrix` accepts is
22702270
permissible here too.
22712271
2272-
``ss(args, inputs=['u1', ..., 'up'], outputs=['y1', ..., 'yq'],
2273-
states=['x1', ..., 'xn'])
2272+
``ss(args, inputs=['u1', ..., 'up'], outputs=['y1', ..., 'yq'], states=['x1', ..., 'xn'])``
22742273
Create a system with named input, output, and state signals.
22752274
22762275
Parameters

control/passivity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def ispassive(sys, ofp_index=0, ifp_index=0):
281281
guaranteed to have an output of True (the system might not be passive with
282282
both indices at the same time).
283283
284-
For more details, see [1].
284+
For more details, see [1]_.
285285
286286
References
287287
----------

control/sisotool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
213213
derivative terms are given instead by Kp, Ki*dt/2*(z+1)/(z-1), and
214214
Kd/dt*(z-1)/z, respectively.
215215
216+
::
217+
216218
------> C_ff ------ d
217219
| | |
218220
r | e V V u y

control/tests/kwargs_test.py

Lines changed: 65 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -75,79 +75,74 @@ def test_kwarg_search(module, prefix):
7575
test_kwarg_search(obj, prefix + obj.__name__ + '.')
7676

7777

78-
@pytest.mark.usefixtures('editsdefaults')
79-
def test_unrecognized_kwargs():
78+
@pytest.mark.parametrize(
79+
"function, nsssys, ntfsys, moreargs, kwargs",
80+
[(control.dlqe, 1, 0, ([[1]], [[1]]), {}),
81+
(control.dlqr, 1, 0, ([[1, 0], [0, 1]], [[1]]), {}),
82+
(control.drss, 0, 0, (2, 1, 1), {}),
83+
(control.input_output_response, 1, 0, ([0, 1, 2], [1, 1, 1]), {}),
84+
(control.lqe, 1, 0, ([[1]], [[1]]), {}),
85+
(control.lqr, 1, 0, ([[1, 0], [0, 1]], [[1]]), {}),
86+
(control.linearize, 1, 0, (0, 0), {}),
87+
(control.pzmap, 1, 0, (), {}),
88+
(control.rlocus, 0, 1, ( ), {}),
89+
(control.root_locus, 0, 1, ( ), {}),
90+
(control.rss, 0, 0, (2, 1, 1), {}),
91+
(control.set_defaults, 0, 0, ('control',), {'default_dt': True}),
92+
(control.ss, 0, 0, (0, 0, 0, 0), {'dt': 1}),
93+
(control.ss2io, 1, 0, (), {}),
94+
(control.ss2tf, 1, 0, (), {}),
95+
(control.summing_junction, 0, 0, (2,), {}),
96+
(control.tf, 0, 0, ([1], [1, 1]), {}),
97+
(control.tf2io, 0, 1, (), {}),
98+
(control.tf2ss, 0, 1, (), {}),
99+
(control.InputOutputSystem, 0, 0, (),
100+
{'inputs': 1, 'outputs': 1, 'states': 1}),
101+
(control.InputOutputSystem.linearize, 1, 0, (0, 0), {}),
102+
(control.StateSpace, 0, 0, ([[-1, 0], [0, -1]], [[1], [1]], [[1, 1]], 0), {}),
103+
(control.TransferFunction, 0, 0, ([1], [1, 1]), {})]
104+
)
105+
def test_unrecognized_kwargs(function, nsssys, ntfsys, moreargs, kwargs,
106+
mplcleanup, editsdefaults):
107+
# Create SISO systems for use in parameterized tests
108+
sssys = control.ss([[-1, 1], [0, -1]], [[0], [1]], [[1, 0]], 0, dt=None)
109+
tfsys = control.tf([1], [1, 1])
110+
111+
args = (sssys, )*nsssys + (tfsys, )*ntfsys + moreargs
112+
113+
# Call the function normally and make sure it works
114+
function(*args, **kwargs)
115+
116+
# Now add an unrecognized keyword and make sure there is an error
117+
with pytest.raises(TypeError, match="unrecognized keyword"):
118+
function(*args, **kwargs, unknown=None)
119+
120+
121+
@pytest.mark.parametrize(
122+
"function, nsysargs, moreargs, kwargs",
123+
[(control.bode, 1, (), {}),
124+
(control.bode_plot, 1, (), {}),
125+
(control.describing_function_plot, 1,
126+
(control.descfcn.saturation_nonlinearity(1), [1, 2, 3, 4]), {}),
127+
(control.gangof4, 2, (), {}),
128+
(control.gangof4_plot, 2, (), {}),
129+
(control.nyquist, 1, (), {}),
130+
(control.nyquist_plot, 1, (), {}),
131+
(control.singular_values_plot, 1, (), {})]
132+
)
133+
def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
80134
# Create a SISO system for use in parameterized tests
81135
sys = control.ss([[-1, 1], [0, -1]], [[0], [1]], [[1, 0]], 0, dt=None)
82136

83-
table = [
84-
[control.dlqe, (sys, [[1]], [[1]]), {}],
85-
[control.dlqr, (sys, [[1, 0], [0, 1]], [[1]]), {}],
86-
[control.drss, (2, 1, 1), {}],
87-
[control.input_output_response, (sys, [0, 1, 2], [1, 1, 1]), {}],
88-
[control.lqe, (sys, [[1]], [[1]]), {}],
89-
[control.lqr, (sys, [[1, 0], [0, 1]], [[1]]), {}],
90-
[control.linearize, (sys, 0, 0), {}],
91-
[control.pzmap, (sys,), {}],
92-
[control.rlocus, (control.tf([1], [1, 1]), ), {}],
93-
[control.root_locus, (control.tf([1], [1, 1]), ), {}],
94-
[control.rss, (2, 1, 1), {}],
95-
[control.set_defaults, ('control',), {'default_dt': True}],
96-
[control.ss, (0, 0, 0, 0), {'dt': 1}],
97-
[control.ss2io, (sys,), {}],
98-
[control.ss2tf, (sys,), {}],
99-
[control.summing_junction, (2,), {}],
100-
[control.tf, ([1], [1, 1]), {}],
101-
[control.tf2io, (control.tf([1], [1, 1]),), {}],
102-
[control.tf2ss, (control.tf([1], [1, 1]),), {}],
103-
[control.InputOutputSystem, (),
104-
{'inputs': 1, 'outputs': 1, 'states': 1}],
105-
[control.InputOutputSystem.linearize, (sys, 0, 0), {}],
106-
[control.StateSpace, ([[-1, 0], [0, -1]], [[1], [1]], [[1, 1]], 0), {}],
107-
[control.TransferFunction, ([1], [1, 1]), {}],
108-
]
109-
110-
for function, args, kwargs in table:
111-
# Call the function normally and make sure it works
112-
function(*args, **kwargs)
113-
114-
# Now add an unrecognized keyword and make sure there is an error
115-
with pytest.raises(TypeError, match="unrecognized keyword"):
116-
function(*args, **kwargs, unknown=None)
117-
118-
# If we opened any figures, close them to avoid matplotlib warnings
119-
if plt.gca():
120-
plt.close('all')
121-
122-
123-
def test_matplotlib_kwargs():
124-
# Create a SISO system for use in parameterized tests
125-
sys = control.ss([[-1, 1], [0, -1]], [[0], [1]], [[1, 0]], 0, dt=None)
126-
ctl = control.ss([[-1, 1], [0, -1]], [[0], [1]], [[1, 0]], 0, dt=None)
127-
128-
table = [
129-
[control.bode, (sys, ), {}],
130-
[control.bode_plot, (sys, ), {}],
131-
[control.describing_function_plot,
132-
(sys, control.descfcn.saturation_nonlinearity(1), [1, 2, 3, 4]), {}],
133-
[control.gangof4, (sys, ctl), {}],
134-
[control.gangof4_plot, (sys, ctl), {}],
135-
[control.nyquist, (sys, ), {}],
136-
[control.nyquist_plot, (sys, ), {}],
137-
[control.singular_values_plot, (sys, ), {}],
138-
]
139-
140-
for function, args, kwargs in table:
141-
# Call the function normally and make sure it works
142-
function(*args, **kwargs)
143-
144-
# Now add an unrecognized keyword and make sure there is an error
145-
with pytest.raises(AttributeError, match="has no property"):
146-
function(*args, **kwargs, unknown=None)
147-
148-
# If we opened any figures, close them to avoid matplotlib warnings
149-
if plt.gca():
150-
plt.close('all')
137+
# Call the function normally and make sure it works
138+
args = (sys, )*nsysargs + moreargs
139+
function(*args, **kwargs)
140+
141+
# Now add an unrecognized keyword and make sure there is an error
142+
with pytest.raises(AttributeError,
143+
match="(has no property|unexpected keyword)"):
144+
function(*args, **kwargs, unknown=None)
145+
151146

152147

153148
#

control/tests/passivity_test.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Author: Mark Yeatman
2+
Author: Mark Yeatman
33
Date: May 30, 2022
44
'''
55
import pytest
@@ -99,20 +99,17 @@ def test_system_dimension():
9999

100100

101101
@pytest.mark.parametrize(
102-
"test_input,expected",
102+
"systemmatrices, expected",
103103
[((A, B, C, D*0.0), True),
104104
((A_d, B, C, D), True),
105-
((A*1e12, B, C, D*0), True),
105+
pytest.param((A*1e12, B, C, D*0), True,
106+
marks=pytest.mark.xfail(reason="gh-761")),
106107
((A, B*0, C*0, D), True),
107108
((A*0, B, C, D), True),
108109
((A*0, B*0, C*0, D*0), True)])
109-
def test_ispassive_edge_cases(test_input, expected):
110-
A = test_input[0]
111-
B = test_input[1]
112-
C = test_input[2]
113-
D = test_input[3]
114-
sys = ss(A, B, C, D)
115-
assert(passivity.ispassive(sys) == expected)
110+
def test_ispassive_edge_cases(systemmatrices, expected):
111+
sys = ss(*systemmatrices)
112+
assert passivity.ispassive(sys) == expected
116113

117114

118115
def test_rho_and_nu_are_none():

doc/conventions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ of linear time-invariant (LTI) systems:
2929
3030
where u is the input, y is the output, and x is the state.
3131

32-
To create a state space system, use the :fun:`ss` function:
32+
To create a state space system, use the :func:`ss` function:
3333

3434
sys = ct.ss(A, B, C, D)
3535

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy