def test_properties(self): # Test setters/getters for cross class properties. # This implicitly tests to_ss() and to_zpk() # Getters s = TransferFunction([1, 0], [1, -1]) assert_equal(s.poles, [1]) assert_equal(s.zeros, [0]) assert_equal(s.gain, 1) assert_equal(s.A, 1) assert_equal(s.B, 1) assert_equal(s.C, 1) assert_equal(s.D, 1) # state space setters s2 = TransferFunction([2, 3], [4, 5]) s2.A = 1 s2.B = 1 s2.C = 1 s2.D = 1 self._compare_systems(s, s2) # zpk setters s2 = TransferFunction([2, 3], [4, 5]) s2.poles = 1 s2.zeros = 0 s2.gain = 1 self._compare_systems(s, s2)
def test_conversion(self): # Check the conversion functions s = TransferFunction([1, 0], [1, -1]) assert_(isinstance(s.to_ss(), StateSpace)) assert_(isinstance(s.to_tf(), TransferFunction)) assert_(isinstance(s.to_zpk(), ZerosPolesGain)) # Make sure copies work assert_(TransferFunction(s) is not s) assert_(s.to_tf() is not s)
def test_initialization(self): # Check that all initializations work s = TransferFunction(1, 1) s = TransferFunction([1], [2]) s = TransferFunction(np.array([1]), np.array([2]))