コード例 #1
0
    def test_to_laplace_regularizer_kwarg(self):
        expected_L_normed = [
            [0, 1 / sqrt(6), 0],
            [1 / sqrt(6), 0, 1 / sqrt(6)],
            [0, 1 / sqrt(6), 0],
        ]
        L_normed = gus.to_laplace(self.A, form="R-DAD", regularizer=1.0)

        self.assertTrue(np.allclose(L_normed, expected_L_normed, rtol=1e-04))
コード例 #2
0
    def test_to_laplace_IDAD(self):
        expected_L_normed = [
            [1, -1 / (sqrt(2)), 0],
            [-1 / (sqrt(2)), 1, -1 / (sqrt(2))],
            [0, -1 / (sqrt(2)), 1],
        ]

        L_normed = gus.to_laplace(self.A, form="I-DAD")
        self.assertTrue(np.allclose(L_normed, expected_L_normed, rtol=1e-04))
コード例 #3
0
 def test_to_laplace_directed(self):
     expected_L_normed = [
         [0, 1 / 5, sqrt(5) / 10, 0.2],
         [0, 0, 0, sqrt(15) / 15],
         [0, sqrt(5) / 10, 0, sqrt(5) / 10],
         [0, sqrt(5) / 10, 0.25, 0],
     ]
     L_normed = gus.to_laplace(self.B, form="R-DAD")
     self.assertTrue(np.allclose(L_normed, expected_L_normed, rtol=1e-04))
コード例 #4
0
    def test_to_laplace_RDAD(self):
        expected_L_normed = [
            [0, 3 / sqrt(70), 0],
            [3 / sqrt(70), 0, 3 / sqrt(70)],
            [0, 3 / sqrt(70), 0],
        ]

        L_normed = gus.to_laplace(self.A, form="R-DAD")

        self.assertTrue(np.allclose(L_normed, expected_L_normed, rtol=1e-04))
コード例 #5
0
 def test_to_laplace_unsuported_regularizer(self):
     with self.assertRaises(TypeError):
         gus.to_laplace(self.A, form="R-DAD", regularizer="2")
     with self.assertRaises(TypeError):
         gus.to_laplace(self.A, form="R-DAD", regularizer=[1, 2, 3])
     with self.assertRaises(ValueError):
         gus.to_laplace(self.A, form="R-DAD", regularizer=-1.0)
コード例 #6
0
 def test_to_laplace_unsuported(self):
     with self.assertRaises(TypeError):
         gus.to_laplace(self.A, form="MOM")
コード例 #7
0
    def test_to_laplace_symmetric(self):
        L_normed = gus.to_laplace(self.A, form="DAD")

        self.assertTrue(gus.is_symmetric(L_normed))