コード例 #1
0
ファイル: test_nlinalg.py プロジェクト: ricardoV94/aesara
    def test_numpy_compare(self):
        rng = np.random.RandomState(utt.fetch_seed())

        M = matrix("A", dtype=config.floatX)
        V = vector("V", dtype=config.floatX)

        a = rng.rand(4, 4).astype(config.floatX)
        b = rng.rand(4).astype(config.floatX)

        A = (
            [None, "fro", "inf", "-inf", 1, -1, None, "inf", "-inf", 0, 1, -1, 2, -2],
            [M, M, M, M, M, M, V, V, V, V, V, V, V, V],
            [a, a, a, a, a, a, b, b, b, b, b, b, b, b],
            [None, "fro", inf, -inf, 1, -1, None, inf, -inf, 0, 1, -1, 2, -2],
        )

        for i in range(0, 14):
            f = function([A[1][i]], norm(A[1][i], A[0][i]))
            t_n = f(A[2][i])
            n_n = np.linalg.norm(A[2][i], A[3][i])
            assert _allclose(n_n, t_n)
コード例 #2
0
ファイル: test_nlinalg.py プロジェクト: geofiber/aesara
 def test_tensor_input(self):
     with pytest.raises(NotImplementedError):
         norm(np.random.rand(3, 4, 5), None)
コード例 #3
0
ファイル: test_nlinalg.py プロジェクト: geofiber/aesara
 def test_non_tensorial_input(self):
     with pytest.raises(ValueError):
         norm(3, None)
コード例 #4
0
ファイル: test_nlinalg.py プロジェクト: geofiber/aesara
 def test_wrong_type_of_ord_for_matrix(self):
     with pytest.raises(ValueError):
         norm([[2, 1], [3, 4]], 0)
コード例 #5
0
ファイル: test_nlinalg.py プロジェクト: geofiber/aesara
 def test_wrong_type_of_ord_for_vector(self):
     with pytest.raises(ValueError):
         norm([2, 1], "fro")