def testGramsys(self):
     num = [1.]
     den = [1., 1., 1.]
     sys = tf(num, den)
     with pytest.raises(ValueError):
         gram(sys, 'o')
     with pytest.raises(ValueError):
         gram(sys, 'c')
 def testGramWo2(self, matarrayin):
     A = matarrayin([[1., -2.], [3., -4.]])
     B = matarrayin([[5.], [7.]])
     C = matarrayin([[6., 8.]])
     D = matarrayin([[9.]])
     sys = ss(A, B, C, D)
     Wotrue = np.array([[198., -72.], [-72., 44.]])
     Wo = gram(sys, 'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
 def testGramRc(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Rctrue = np.matrix("4.30116263 5.6961343; 0. 0.23249528")
     Rc = gram(sys, 'cf')
     np.testing.assert_array_almost_equal(Rc, Rctrue)
 def testGramWc(self):
     A = np.array([[1., -2.], [3., -4.]])
     B = np.array([[5., 6.], [7., 8.]])
     C = np.array([[4., 5.], [6., 7.]])
     D = np.array([[13., 14.], [15., 16.]])
     sys = ss(A, B, C, D)
     Wctrue = np.array([[18.5, 24.5], [24.5, 32.5]])
     Wc = gram(sys, 'c')
     np.testing.assert_array_almost_equal(Wc, Wctrue)
 def testGramWo(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Wotrue = np.matrix("257.5 -94.5; -94.5 56.5")
     Wo = gram(sys,'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
 def testGramWo2(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5.; 7.")
     C = np.matrix("6. 8.")
     D = np.matrix("9.")
     sys = ss(A,B,C,D)
     Wotrue = np.matrix("198. -72.; -72. 44.")
     Wo = gram(sys,'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
 def testGramRc(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Rctrue = np.matrix("4.30116263 5.6961343; 0. 0.23249528")
     Rc = gram(sys,'cf')
     np.testing.assert_array_almost_equal(Rc, Rctrue)
 def testGramWc(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Wctrue = np.matrix("18.5 24.5; 24.5 32.5")
     Wc = gram(sys,'c')
     np.testing.assert_array_almost_equal(Wc, Wctrue)
 def testGramRo(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Rotrue = np.matrix("16.04680654 -5.8890222; 0. 4.67112593")
     Ro = gram(sys,'of')
     np.testing.assert_array_almost_equal(Ro, Rotrue)
Example #10
0
 def testGramRo(self, matarrayin):
     A = matarrayin([[1., -2.], [3., -4.]])
     B = matarrayin([[5., 6.], [7., 8.]])
     C = matarrayin([[4., 5.], [6., 7.]])
     D = matarrayin([[13., 14.], [15., 16.]])
     sys = ss(A, B, C, D)
     Rotrue = np.array([[16.04680654, -5.8890222], [0., 4.67112593]])
     Ro = gram(sys, 'of')
     np.testing.assert_array_almost_equal(Ro, Rotrue)
Example #11
0
 def testGramWo(self, matarrayin):
     A = matarrayin([[1., -2.], [3., -4.]])
     B = matarrayin([[5., 6.], [7., 8.]])
     C = matarrayin([[4., 5.], [6., 7.]])
     D = matarrayin([[13., 14.], [15., 16.]])
     sys = ss(A, B, C, D)
     Wotrue = np.array([[257.5, -94.5], [-94.5, 56.5]])
     Wo = gram(sys, 'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
Example #12
0
 def testGramWo2(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5.; 7.")
     C = np.matrix("6. 8.")
     D = np.matrix("9.")
     sys = ss(A, B, C, D)
     Wotrue = np.matrix("198. -72.; -72. 44.")
     Wo = gram(sys, 'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
 def testGramRo(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Rotrue = np.matrix("16.04680654 -5.8890222; 0. 4.67112593")
     Ro = gram(sys, 'of')
     np.testing.assert_array_almost_equal(Ro, Rotrue)
Example #14
0
 def testGramWo(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Wotrue = np.matrix("257.5 -94.5; -94.5 56.5")
     Wo = gram(sys, 'o')
     np.testing.assert_array_almost_equal(Wo, Wotrue)
Example #15
0
 def testGramWc(self):
     A = np.matrix("1. -2.; 3. -4.")
     B = np.matrix("5. 6.; 7. 8.")
     C = np.matrix("4. 5.; 6. 7.")
     D = np.matrix("13. 14.; 15. 16.")
     sys = ss(A, B, C, D)
     Wctrue = np.matrix("18.5 24.5; 24.5 32.5")
     Wc = gram(sys, 'c')
     np.testing.assert_array_almost_equal(Wc, Wctrue)
Example #16
0
 def testGramRc(self, matarrayin):
     A = matarrayin([[1., -2.], [3., -4.]])
     B = matarrayin([[5., 6.], [7., 8.]])
     C = matarrayin([[4., 5.], [6., 7.]])
     D = matarrayin([[13., 14.], [15., 16.]])
     sys = ss(A, B, C, D)
     Rctrue = np.array([[4.30116263, 5.6961343], [0., 0.23249528]])
     Rc = gram(sys, 'cf')
     np.testing.assert_array_almost_equal(Rc, Rctrue)
Example #17
0
    def testGramWc(self, matarrayin, matarrayout):
        A = matarrayin([[1., -2.], [3., -4.]])
        B = matarrayin([[5., 6.], [7., 8.]])
        C = matarrayin([[4., 5.], [6., 7.]])
        D = matarrayin([[13., 14.], [15., 16.]])
        sys = ss(A, B, C, D)
        Wctrue = np.array([[18.5, 24.5], [24.5, 32.5]])

        with check_deprecated_matrix():
            Wc = gram(sys, 'c')

        assert ismatarrayout(Wc)
        np.testing.assert_array_almost_equal(Wc, Wctrue)
    def test_gram_wc_deprecated(self):
        A = np.array([[1., -2.], [3., -4.]])
        B = np.array([[5., 6.], [7., 8.]])
        C = np.array([[4., 5.], [6., 7.]])
        D = np.array([[13., 14.], [15., 16.]])
        sys = ss(A, B, C, D)

        # Check that default type generates a warning
        # TODO: remove this check with matrix type is deprecated
        with warnings.catch_warnings(record=True) as w:
            use_numpy_matrix(True)
            self.assertTrue(issubclass(w[-1].category, UserWarning))
            
            Wc = gram(sys, 'c')
            self.assertTrue(isinstance(Wc, np.ndarray))
            use_numpy_matrix(False)