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

Commita9a6226

Browse files
committed
update params docstrings + warnings per@sawyerbfuller suggestion
1 parent878cf98 commita9a6226

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

‎control/iosys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ def dynamics(self, t, x, u, params=None):
376376
right hand side of the dynamical system. If the system is continuous,
377377
returns the time derivative
378378
379-
dx/dt = f(t, x, u, params)
379+
dx/dt = f(t, x, u[, params])
380380
381381
where `f` is the system's (possibly nonlinear) dynamics function.
382382
If the system is discrete-time, returns the next value of `x`:
383383
384-
x[t+dt] = f(t, x[t], u[t], params)
384+
x[t+dt] = f(t, x[t], u[t][, params])
385385
386386
where `t` is a scalar.
387387

‎control/statesp.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ def dcgain(self, warn_infinite=False):
13891389
"""
13901390
returnself._dcgain(warn_infinite)
13911391

1392-
defdynamics(self,t,x,u=None):
1392+
defdynamics(self,t,x,u=None,params=None):
13931393
"""Compute the dynamics of the system
13941394
13951395
Given input `u` and state `x`, returns the dynamics of the state-space
@@ -1423,6 +1423,9 @@ def dynamics(self, t, x, u=None):
14231423
dx/dt or x[t+dt] : ndarray
14241424
14251425
"""
1426+
ifparamsisnotNone:
1427+
warn("params keyword ignored for StateSpace object")
1428+
14261429
x=np.reshape(x, (-1,1))# force to a column in case matrix
14271430
ifnp.size(x)!=self.nstates:
14281431
raiseValueError("len(x) must be equal to number of states")
@@ -1435,7 +1438,7 @@ def dynamics(self, t, x, u=None):
14351438
return (self.A @x).reshape((-1,)) \
14361439
+ (self.B @u).reshape((-1,))# return as row vector
14371440

1438-
defoutput(self,t,x,u=None):
1441+
defoutput(self,t,x,u=None,params=None):
14391442
"""Compute the output of the system
14401443
14411444
Given input `u` and state `x`, returns the output `y` of the
@@ -1465,6 +1468,9 @@ def output(self, t, x, u=None):
14651468
-------
14661469
y : ndarray
14671470
"""
1471+
ifparamsisnotNone:
1472+
warn("params keyword ignored for StateSpace object")
1473+
14681474
x=np.reshape(x, (-1,1))# force to a column in case matrix
14691475
ifnp.size(x)!=self.nstates:
14701476
raiseValueError("len(x) must be equal to number of states")

‎control/tests/statesp_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,3 +1158,15 @@ def test_linfnorm_ct_mimo(self, ct_siso):
11581158
gpeak,fpeak=linfnorm(sys)
11591159
np.testing.assert_allclose(gpeak,refgpeak)
11601160
np.testing.assert_allclose(fpeak,reffpeak)
1161+
1162+
1163+
# Make sure that using params for StateSpace objects generates a warning
1164+
deftest_params_warning():
1165+
sys=StateSpace(-1,1,1,0)
1166+
1167+
withpytest.warns(UserWarning,match="params keyword ignored"):
1168+
sys.dynamics(0, [0], [0], {'k':5})
1169+
1170+
withpytest.warns(UserWarning,match="params keyword ignored"):
1171+
sys.output(0, [0], [0], {'k':5})
1172+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp