8000 use standard method to assess whether a system is a static gain, so t… · python-control/python-control@588e046 · GitHub
[go: up one dir, main page]

Skip to content

Commit 588e046

Browse files
committed
use standard method to assess whether a system is a static gain, so that it has dt=None by default, when constructing a LinearIOSystem
1 parent a03f5f1 commit 588e046

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

control/statesp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,8 @@ def __init__(self, *args, init_namedio=True, **kwargs):
346346
defaults = args[0] if len(args) == 1 else \
347347
{'inputs': D.shape[1], 'outputs': D.shape[0],
348348
'states': A.shape[0]}
349-
static = (A.size == 0)
350349
name, inputs, outputs, states, dt = _process_namedio_keywords(
351-
kwargs, defaults, static=static, end=True)
350+
kwargs, defaults, static=self._isstatic(), end=True)
352351

353352
# Initialize LTI (NamedIOSystem) object
354353
super().__init__(

control/tests/iosys_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class TSys:
4141
[[-1, 1], [0, -2]], [[0, 1], [1, 0]],
4242
[[1, 0], [0, 1]], np.zeros((2, 2)))
4343

44+
# Create a static gain linear system
45+
T.staticgain = ct.StateSpace(0, 0, 0, 1)
46+
4447
# Create simulation parameters
4548
T.T = np.linspace(0, 10, 100)
4649
T.U = np.sin(T.T)
@@ -70,6 +73,12 @@ def test_linear_iosys(self, tsys):
7073
# system results in a LinearIOSystem
7174
assert isinstance(linsys*iosys, ios.LinearIOSystem)
7275

76+
# Make sure that a static linear system has dt=None
77+
# and otherwise dt is as specified
78+
assert ios.LinearIOSystem(tsys.staticgain).dt is None
79+
assert ios.LinearIOSystem(tsys.staticgain, dt=.1).dt == .1
80+
81+
7382
def test_tf2io(self, tsys):
7483
# Create a transfer function from the state space system
7584
linsys = tsys.siso_linsys

0 commit comments

Comments
 (0)
0