BugFix: DC gain for discrete-time systems · python-control/python-control@3997637
@@ -225,7 +225,8 @@ def testArrayAccessSS(self):
225225226226assert sys1.dt == sys1_11.dt
227227228-def test_dcgain(self):
228+def test_dcgain_cont(self):
229+"""Test DC gain for continuous-time state-space systems"""
229230sys = StateSpace(-2.,6.,5.,0)
230231np.testing.assert_equal(sys.dcgain(), 15.)
231232@@ -236,6 +237,24 @@ def test_dcgain(self):
236237sys3 = StateSpace(0., 1., 1., 0.)
237238np.testing.assert_equal(sys3.dcgain(), np.nan)
238239240+def test_dcgain_discr(self):
241+"""Test DC gain for discrete-time state-space systems"""
242+# static gain
243+sys = StateSpace([], [], [], 2, True)
244+np.testing.assert_equal(sys.dcgain(), 2)
245+246+# averaging filter
247+sys = StateSpace(0.5, 0.5, 1, 0, True)
248+np.testing.assert_almost_equal(sys.dcgain(), 1)
249+250+# differencer
251+sys = StateSpace(0, 1, -1, 1, True)
252+np.testing.assert_equal(sys.dcgain(), 0)
253+254+# summer
255+sys = StateSpace(1, 1, 1, 0, True)
256+np.testing.assert_equal(sys.dcgain(), np.nan)
257+239258240259def test_scalarStaticGain(self):
241260"""Regression: can we create a scalar static gain?"""