BugFix: DC gain for discrete-time systems · python-control/python-control@84033fe
@@ -228,7 +228,8 @@ def testArrayAccessSS(self):
228228229229assert sys1.dt == sys1_11.dt
230230231-def test_dcgain(self):
231+def test_dcgain_cont(self):
232+"""Test DC gain for continuous-time state-space systems"""
232233sys = StateSpace(-2.,6.,5.,0)
233234np.testing.assert_equal(sys.dcgain(), 15.)
234235@@ -239,6 +240,24 @@ def test_dcgain(self):
239240sys3 = StateSpace(0., 1., 1., 0.)
240241np.testing.assert_equal(sys3.dcgain(), np.nan)
241242243+def test_dcgain_discr(self):
244+"""Test DC gain for discrete-time state-space systems"""
245+# static gain
246+sys = StateSpace([], [], [], 2, True)
247+np.testing.assert_equal(sys.dcgain(), 2)
248+249+# averaging filter
250+sys = StateSpace(0.5, 0.5, 1, 0, True)
251+np.testing.assert_almost_equal(sys.dcgain(), 1)
252+253+# differencer
254+sys = StateSpace(0, 1, -1, 1, True)
255+np.testing.assert_equal(sys.dcgain(), 0)
256+257+# summer
258+sys = StateSpace(1, 1, 1, 0, True)
259+np.testing.assert_equal(sys.dcgain(), np.nan)
260+242261243262def test_scalarStaticGain(self):
244263"""Regression: can we create a scalar static gain?"""