Skip to content

Commit

Permalink
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-buildbot authored and syclik committed Jan 3, 2024
1 parent 0277a04 commit c1bf4c4
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 228 deletions.
6 changes: 4 additions & 2 deletions test/unit/math/fwd/prob/dirichlet_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ TEST(ProbDistributions, fvar_fvar_double) {
alpha(i).d_ = 1.0;
}

EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_lpdf(theta, alpha).val_.val_);
EXPECT_FLOAT_EQ(0.6931472,
stan::math::dirichlet_lpdf(theta, alpha).val_.val_);
EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_lpdf(theta, alpha).d_.val_);

Matrix<fvar<fvar<double> >, Dynamic, 1> theta2(4, 1);
Expand All @@ -61,5 +62,6 @@ TEST(ProbDistributions, fvar_fvar_double) {

EXPECT_FLOAT_EQ(-43.40045,
stan::math::dirichlet_lpdf(theta2, alpha2).val_.val_);
EXPECT_FLOAT_EQ(2017.2858, stan::math::dirichlet_lpdf(theta2, alpha2).d_.val_);
EXPECT_FLOAT_EQ(2017.2858,
stan::math::dirichlet_lpdf(theta2, alpha2).d_.val_);
}
3 changes: 2 additions & 1 deletion test/unit/math/fwd/prob/multi_gp_cholesky_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_double) {
lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma);
}

EXPECT_FLOAT_EQ(lp_ref.val_, stan::math::multi_gp_cholesky_lpdf(y, L, w).val_);
EXPECT_FLOAT_EQ(lp_ref.val_,
stan::math::multi_gp_cholesky_lpdf(y, L, w).val_);
EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_cholesky_lpdf(y, L, w).d_);
}

Expand Down
16 changes: 9 additions & 7 deletions test/unit/math/mix/prob/categorical_logit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) {
theta(i).d_ = i;

std::vector<int> ns(0);
EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_lpmf(ns, theta).val_.val());
EXPECT_FLOAT_EQ(0.0,
stan::math::categorical_logit_lpmf(ns, theta).val_.val());

Matrix<fvar<var>, Dynamic, 1> theta_log_softmax = log_softmax(theta);

Expand Down Expand Up @@ -94,19 +95,20 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var_vectorized) {
theta(i).d_.val_ = i;

std::vector<int> ns(0);
EXPECT_FLOAT_EQ(0.0,
stan::math::categorical_logit_lpmf(ns, theta).val_.val_.val());
EXPECT_FLOAT_EQ(
0.0, stan::math::categorical_logit_lpmf(ns, theta).val_.val_.val());

Matrix<fvar<fvar<var> >, Dynamic, 1> theta_log_softmax = log_softmax(theta);

std::vector<int> ms(3);
ms[0] = 1;
ms[1] = 2;
ms[2] = 1;
EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val_.val()
+ theta_log_softmax[1].val_.val_.val()
+ theta_log_softmax[0].val_.val_.val(),
stan::math::categorical_logit_lpmf(ms, theta).val_.val_.val());
EXPECT_FLOAT_EQ(
theta_log_softmax[0].val_.val_.val()
+ theta_log_softmax[1].val_.val_.val()
+ theta_log_softmax[0].val_.val_.val(),
stan::math::categorical_logit_lpmf(ms, theta).val_.val_.val());
EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val_.val()
+ theta_log_softmax[1].d_.val_.val()
+ theta_log_softmax[0].d_.val_.val(),
Expand Down
3 changes: 2 additions & 1 deletion test/unit/math/mix/prob/dirichlet_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ TEST(ProbDistributions, fvar_var) {

EXPECT_FLOAT_EQ(0.6931472,
stan::math::dirichlet_lpdf(theta, alpha).val_.val());
EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_lpdf(theta, alpha).d_.val());
EXPECT_FLOAT_EQ(0.99344212,
stan::math::dirichlet_lpdf(theta, alpha).d_.val());

Matrix<fvar<var>, Dynamic, 1> theta2(4, 1);
theta2 << 0.01, 0.01, 0.8, 0.18;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/mix/prob/inv_wishart_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ TEST(ProbDistributionsInvWishart, fvar_fvar_var) {
Sigma(i, j).d_ = 1.0;
}

EXPECT_NEAR(log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_.val_.val(),
0.01);
EXPECT_NEAR(
log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_.val_.val(), 0.01);
EXPECT_NEAR(-1.4893348387330674,
stan::math::inv_wishart_lpdf(Y, dof, Sigma).d_.val_.val(), 0.01);

Expand Down
3 changes: 1 addition & 2 deletions test/unit/math/mix/prob/lkj_corr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) {
f.val_.val_.val(),
stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val_.val());
EXPECT_FLOAT_EQ(3,
stan::math::lkj_corr_cholesky_lpdf
(Sigma, eta).d_.val_.val());
stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val_.val());
}

TEST(ProbDistributionsLkjCorrCholesky, hessian) {
Expand Down
3 changes: 2 additions & 1 deletion test/unit/math/mix/prob/multinomial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ TEST(ProbDistributionsMultinomial, fvar_var) {
for (int i = 0; i < 3; i++)
theta(i).d_ = 1.0;

EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_lpmf(ns, theta).val_.val());
EXPECT_FLOAT_EQ(-2.002481,
stan::math::multinomial_lpmf(ns, theta).val_.val());
EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_lpmf(ns, theta).d_.val());
}

Expand Down
5 changes: 3 additions & 2 deletions test/unit/math/mix/prob/wishart_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ TEST(ProbDistributionsWishart, fvar_fvar_var) {
// computed with MCMCpack in R
double lp = log(8.658e-07);

EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_.val_.val(), 0.01);
EXPECT_NEAR(-0.76893887, stan::math::wishart_lpdf(Y, dof, Sigma).d_.val_.val(),
EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_.val_.val(),
0.01);
EXPECT_NEAR(-0.76893887,
stan::math::wishart_lpdf(Y, dof, Sigma).d_.val_.val(), 0.01);

stan::math::recover_memory();
}
3 changes: 2 additions & 1 deletion test/unit/math/prim/prob/ordered_logistic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ TEST(ProbDistributions, ordered_logistic) {

Eigen::Matrix<double, Eigen::Dynamic, 1> lambda_small(3);
lambda_small << 1, 1, 1;
EXPECT_THROW(ordered_logistic_lpmf(y, lambda_small, c), std::invalid_argument);
EXPECT_THROW(ordered_logistic_lpmf(y, lambda_small, c),
std::invalid_argument);

Eigen::Matrix<double, Eigen::Dynamic, 1> c_small(K - 2);
c_small << -0.3, 0.1;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/math/rev/prob/categorical2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

template <typename T_prob>
void expect_propto_categorical_lpmf(unsigned int n1, T_prob theta1,
unsigned int n2, T_prob theta2,
std::string message) {
unsigned int n2, T_prob theta2,
std::string message) {
expect_eq_diffs(stan::math::categorical_lpmf<false>(n1, theta1),
stan::math::categorical_lpmf<false>(n2, theta2),
stan::math::categorical_lpmf<true>(n1, theta1),
Expand Down
54 changes: 27 additions & 27 deletions test/unit/math/rev/prob/dirichlet2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

template <typename T_prob, typename T_prior_sample_size>
void expect_propto_dirichlet_lpdf(T_prob theta, T_prior_sample_size alpha,
T_prob theta2, T_prior_sample_size alpha2,
std::string message) {
T_prob theta2, T_prior_sample_size alpha2,
std::string message) {
expect_eq_diffs(stan::math::dirichlet_lpdf<false>(theta, alpha),
stan::math::dirichlet_lpdf<false>(theta2, alpha2),
stan::math::dirichlet_lpdf<true>(theta, alpha),
stan::math::dirichlet_lpdf<true>(theta2, alpha2), message);
}

class AgradDistributionsDirichlet : public ::testing::Test {
protected:
protected:
virtual void SetUp() {
theta.resize(3, 1);
theta << 0.2, 0.3, 0.5;
Expand All @@ -37,23 +37,23 @@ TEST_F(AgradDistributionsDirichlet, Propto) {
using stan::math::to_var;
using stan::math::var;
expect_propto_dirichlet_lpdf(to_var(theta), to_var(alpha), to_var(theta2),
to_var(alpha2), "var: theta and alpha");
to_var(alpha2), "var: theta and alpha");
}
TEST_F(AgradDistributionsDirichlet, ProptoTheta) {
using Eigen::Dynamic;
using Eigen::Matrix;
using stan::math::to_var;
using stan::math::var;
expect_propto_dirichlet_lpdf(to_var(theta), alpha, to_var(theta2), alpha,
"var: theta");
"var: theta");
}
TEST_F(AgradDistributionsDirichlet, ProptoAlpha) {
using Eigen::Dynamic;
using Eigen::Matrix;
using stan::math::to_var;
using stan::math::var;
expect_propto_dirichlet_lpdf(theta, to_var(alpha), theta, to_var(alpha2),
"var: alpha");
"var: alpha");
}
TEST_F(AgradDistributionsDirichlet, Bounds) {
using Eigen::Dynamic;
Expand All @@ -73,66 +73,66 @@ TEST_F(AgradDistributionsDirichlet, Bounds) {
good_theta << 1.0, 0.0;
good_alpha << 2, 3;
EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), to_var(good_alpha)))
<< "elements of theta can be 0";
<< "elements of theta can be 0";
EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), good_alpha))
<< "elements of theta can be 0";
<< "elements of theta can be 0";
EXPECT_NO_THROW(dirichlet_lpdf(good_theta, to_var(good_alpha)))
<< "elements of theta can be 0";
<< "elements of theta can be 0";

bad_theta << 0.25, 0.25;
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)),
std::domain_error)
<< "sum of theta is not 1";
<< "sum of theta is not 1";
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error)
<< "sum of theta is not 1";
<< "sum of theta is not 1";
EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error)
<< "sum of theta is not 1";
<< "sum of theta is not 1";

bad_theta << -0.25, 1.25;
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)),
std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";
EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";

bad_theta << -0.25, 1.25;
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)),
std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";
EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";
EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error)
<< "theta has element less than 0";
<< "theta has element less than 0";

bad_alpha << 0.0, 1.0;
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)),
std::domain_error)
<< "alpha has element equal to 0";
<< "alpha has element equal to 0";
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha), std::domain_error)
<< "alpha has element equal to 0";
<< "alpha has element equal to 0";
EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)), std::domain_error)
<< "alpha has element equal to 0";
<< "alpha has element equal to 0";

bad_alpha << -0.5, 1.0;
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)),
std::domain_error)
<< "alpha has element less than 0";
<< "alpha has element less than 0";
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha), std::domain_error)
<< "alpha has element less than 0";
<< "alpha has element less than 0";
EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)), std::domain_error)
<< "alpha has element less than 0";
<< "alpha has element less than 0";

bad_alpha = Matrix<double, Dynamic, 1>(4, 1);
bad_alpha << 1, 2, 3, 4;
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)),
std::invalid_argument)
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha),
std::invalid_argument)
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)),
std::invalid_argument)
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
<< "size mismatch: theta is a 2-vector, alpha is a 4-vector";
}
51 changes: 26 additions & 25 deletions test/unit/math/rev/prob/inv_wishart2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

template <typename T_y, typename T_dof, typename T_scale>
void expect_propto_inv_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2,
T_dof nu2, T_scale S2, std::string message) {
T_dof nu2, T_scale S2,
std::string message) {
expect_eq_diffs(stan::math::inv_wishart_lpdf<false>(W1, nu1, S1),
stan::math::inv_wishart_lpdf<false>(W2, nu2, S2),
stan::math::inv_wishart_lpdf<true>(W1, nu1, S1),
stan::math::inv_wishart_lpdf<true>(W2, nu2, S2), message);
}

class AgradDistributionsInvWishart : public ::testing::Test {
protected:
protected:
virtual void SetUp() {
Y1.resize(2, 2);
Y1 << 2.011108, -11.20661, -11.20661, 112.94139;
Expand Down Expand Up @@ -42,39 +43,39 @@ class AgradDistributionsInvWishart : public ::testing::Test {

TEST_F(AgradDistributionsInvWishart, Propto) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(to_var(Y1), to_var(nu1), to_var(S1), to_var(Y2),
to_var(nu2), to_var(S2),
"var: y, nu, and sigma");
expect_propto_inv_wishart_lpdf(to_var(Y1), to_var(nu1), to_var(S1),
to_var(Y2), to_var(nu2), to_var(S2),
"var: y, nu, and sigma");
}
TEST_F(AgradDistributionsInvWishart, ProptoY) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(to_var(Y1), nu1, S1, to_var(Y2), nu1, S1,
"var: y");
"var: y");
}
TEST_F(AgradDistributionsInvWishart, ProptoYNu) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(to_var(Y1), to_var(nu1), S1, to_var(Y2),
to_var(nu2), S1, "var: y, and nu");
to_var(nu2), S1, "var: y, and nu");
}
TEST_F(AgradDistributionsInvWishart, ProptoYSigma) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(to_var(Y1), nu1, to_var(S1), to_var(Y2), nu1,
to_var(S2), "var: y and sigma");
to_var(S2), "var: y and sigma");
}
TEST_F(AgradDistributionsInvWishart, ProptoNu) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(Y1, to_var(nu1), S1, Y1, to_var(nu2), S1,
"var: nu");
"var: nu");
}
TEST_F(AgradDistributionsInvWishart, ProptoNuSigma) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(Y1, to_var(nu1), to_var(S1), Y1, to_var(nu2),
to_var(S2), "var: nu and sigma");
to_var(S2), "var: nu and sigma");
}
TEST_F(AgradDistributionsInvWishart, ProptoSigma) {
using stan::math::to_var;
expect_propto_inv_wishart_lpdf(Y1, nu1, to_var(S1), Y1, nu1, to_var(S2),
"var: sigma");
"var: sigma");
}

TEST(InvWishart, check_varis_on_stack) {
Expand All @@ -88,34 +89,34 @@ TEST(InvWishart, check_varis_on_stack) {
S << 1.848220, 1.899623, 1.899623, 12.751941;

test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(to_var(W), to_var(nu), to_var(S)));
stan::math::inv_wishart_lpdf<false>(to_var(W), to_var(nu), to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(to_var(W), to_var(nu), S));
stan::math::inv_wishart_lpdf<false>(to_var(W), to_var(nu), S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(to_var(W), nu, to_var(S)));
stan::math::inv_wishart_lpdf<false>(to_var(W), nu, to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(to_var(W), nu, S));
stan::math::inv_wishart_lpdf<false>(to_var(W), nu, S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(W, to_var(nu), to_var(S)));
stan::math::inv_wishart_lpdf<false>(W, to_var(nu), to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(W, to_var(nu), S));
stan::math::inv_wishart_lpdf<false>(W, to_var(nu), S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<false>(W, nu, to_var(S)));
stan::math::inv_wishart_lpdf<false>(W, nu, to_var(S)));

test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(to_var(W), to_var(nu), to_var(S)));
stan::math::inv_wishart_lpdf<true>(to_var(W), to_var(nu), to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(to_var(W), to_var(nu), S));
stan::math::inv_wishart_lpdf<true>(to_var(W), to_var(nu), S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(to_var(W), nu, to_var(S)));
stan::math::inv_wishart_lpdf<true>(to_var(W), nu, to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(to_var(W), nu, S));
stan::math::inv_wishart_lpdf<true>(to_var(W), nu, S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(W, to_var(nu), to_var(S)));
stan::math::inv_wishart_lpdf<true>(W, to_var(nu), to_var(S)));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(W, to_var(nu), S));
stan::math::inv_wishart_lpdf<true>(W, to_var(nu), S));
test::check_varis_on_stack(
stan::math::inv_wishart_lpdf<true>(W, nu, to_var(S)));
stan::math::inv_wishart_lpdf<true>(W, nu, to_var(S)));

stan::math::recover_memory();
}
Loading

0 comments on commit c1bf4c4

Please sign in to comment.