示例#1
0
    def test_conversion(self):
        # Check the conversion functions
        s = StateSpace(1, 2, 3, 4)
        assert_(isinstance(s.to_ss(), StateSpace))
        assert_(isinstance(s.to_tf(), TransferFunction))
        assert_(isinstance(s.to_zpk(), ZerosPolesGain))

        # Make sure copies work
        assert_(StateSpace(s) is not s)
        assert_(s.to_ss() is not s)
示例#2
0
    def test_properties(self):
        # Test setters/getters for cross class properties.
        # This implicitly tests to_tf() and to_zpk()

        # Getters
        s = StateSpace(1, 1, 1, 1)
        assert_equal(s.num, [1, 0])
        assert_equal(s.den, [1, -1])
        assert_equal(s.poles, [1])
        assert_equal(s.zeros, [0])
        assert_equal(s.gain, 1)

        # transfer function setters
        s2 = StateSpace(2, 2, 2, 2)
        s2.num = [1, 0]
        s2.den = [1, -1]
        self._compare_systems(s, s2)

        # zpk setters
        s2 = StateSpace(2, 2, 2, 2)
        s2.poles = 1
        s2.zeros = 0
        s2.gain = 1
        self._compare_systems(s, s2)
示例#3
0
 def test_initialization(self):
     # Check that all initializations work
     s = StateSpace(1, 1, 1, 1)
     s = StateSpace([1], [2], [3], [4])
     s = StateSpace(np.array([[1, 2], [3, 4]]), np.array([[1], [2]]),
                    np.array([[1, 0]]), np.array([[0]]))