@pytest.mark.parametrize('x', [randn(4, 10), randn(4, 1)])
@pytest.mark.parametrize('mu', [randn(4, 10), randn(4, 1)])
@pytest.mark.parametrize('cov_sqrt', [randn(4, 4), np.eye(4)])
def test_multivariate_normal(session_tf, x, mu, cov_sqrt):
    cov = np.dot(cov_sqrt, cov_sqrt.T)
    L = np.linalg.cholesky(cov)
    x_tf = tf.placeholder(settings.float_type)
    mu_tf = tf.placeholder(settings.float_type)
    gp_result = logdensities.multivariate_normal(x_tf, mu_tf, tf.convert_to_tensor(L))
    gp_result = session_tf.run(gp_result, feed_dict={x_tf: x, mu_tf: mu})
    if (mu.shape[1] > 1):
        if (x.shape[1] > 1):
            sp_result = [mvn.logpdf(x[:, i], mu[:, i], cov) for i in range(mu.shape[1])]
        else:
            sp_result = [mvn.logpdf(x.ravel(), mu[:, i], cov) for i in range(mu.shape[1])]
    else:
        sp_result = mvn.logpdf(x.T, mu.ravel(), cov)
    assert_allclose(gp_result, sp_result)
@pytest.mark.parametrize('x', [randn(4, 10), randn(4, 1)])
@pytest.mark.parametrize('mu', [randn(4, 10), randn(4, 1)])
@pytest.mark.parametrize('cov_sqrt', [randn(4, 4), np.eye(4)])
def test_multivariate_normal(session_tf, x, mu, cov_sqrt):
    cov = np.dot(cov_sqrt, cov_sqrt.T)
    L = np.linalg.cholesky(cov)
    x_tf = tf.placeholder(settings.float_type)
    mu_tf = tf.placeholder(settings.float_type)
    gp_result = logdensities.multivariate_normal(x_tf, mu_tf, tf.convert_to_tensor(L))
    gp_result = session_tf.run(gp_result, feed_dict={x_tf: x, mu_tf: mu})
    if (mu.shape[1] > 1):
        if (x.shape[1] > 1):
            sp_result = [mvn.logpdf(x[:, i], mu[:, i], cov) for i in range(mu.shape[1])]
        else:
            sp_result = [mvn.logpdf(x.ravel(), mu[:, i], cov) for i in range(mu.shape[1])]
    else:
        sp_result = mvn.logpdf(x.T, mu.ravel(), cov)
    assert_allclose(gp_result, sp_result)