Skip to content

Commit 63dccf6

Browse files
authored
Merge pull request #3193 from stan-dev/fix/flaky-test-uninit-memory
2 parents 2fe12b4 + 64a6c97 commit 63dccf6

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

test/unit/math/prim/constraint/lb_transform_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TEST(prob_transform, lb_constrain_matrix) {
3737
double lbd = 2.0;
3838

3939
Eigen::VectorXd lb_bad(3);
40+
lb_bad << 1.0, 2.0, 3.0;
4041

4142
// matrix, real
4243
{
@@ -89,10 +90,11 @@ TEST(prob_transform, lb_constrain_std_vector) {
8990
Eigen::VectorXd lb(2);
9091
lb << 2.0, stan::math::NEGATIVE_INFTY;
9192
Eigen::VectorXd lb2(2);
92-
lb << stan::math::NEGATIVE_INFTY, 1.0;
93+
lb2 << stan::math::NEGATIVE_INFTY, 1.0;
9394
double lbd = 2.0;
9495

9596
Eigen::VectorXd lb_bad(3);
97+
lb_bad << 1.0, 2.0, 3.0;
9698

9799
std::vector<Eigen::VectorXd> x_vec = {x, x};
98100
std::vector<Eigen::VectorXd> lb_vec = {lb, lb2};

test/unit/math/prim/constraint/lub_transform_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ TEST(prob_transform, lub_constrain_matrix) {
134134
double lbd = -2.0;
135135

136136
Eigen::VectorXd ub_bad(3);
137+
ub_bad << 1.0, 2.0, 3.0;
138+
137139
Eigen::VectorXd lb_bad(3);
140+
lb_bad << -1.0, -2.0, -3.0;
138141

139142
// matrix, real, real
140143
{
@@ -330,7 +333,9 @@ TEST(prob_transform, lub_constrain_stdvec_matrix) {
330333
double lbd = -2.0;
331334

332335
Eigen::VectorXd ub_bad(3);
336+
ub_bad << 1.0, 2.0, 3.0;
333337
Eigen::VectorXd lb_bad(3);
338+
lb_bad << -1.0, -2.0, -3.0;
334339

335340
std::vector<Eigen::VectorXd> x_vec{x, x};
336341
std::vector<Eigen::VectorXd> ub_vec{ub, ub};

test/unit/math/prim/constraint/ub_transform_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TEST(prob_transform, ub_constrain_matrix) {
3737
double ubd = 2.0;
3838

3939
Eigen::VectorXd ub_bad(3);
40+
ub_bad << 1.0, 2.0, 3.0;
4041

4142
// matrix, real
4243
{
@@ -94,6 +95,7 @@ TEST(prob_transform, ub_constrain_std_vector) {
9495
double ubd = 2.0;
9596

9697
Eigen::VectorXd ub_bad(3);
98+
ub_bad << 1.0, 2.0, 3.0;
9799

98100
std::vector<Eigen::VectorXd> x_vec = {x, 2 * x};
99101
std::vector<Eigen::VectorXd> ub_vec = {ub, ub2};

test/unit/math/prim/fun/fma_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ TEST(MathFunctions, fma_matrix) {
5454
Eigen::RowVectorXd y_rowvec(2);
5555
y_rowvec << 2.0, -3.0;
5656
Eigen::MatrixXd y_mat(2, 2);
57-
x_mat << 1.0, 2.0, -1.0, 1.1;
57+
y_mat << 1.0, 2.0, -1.0, 1.1;
5858

5959
double z_scalar = 3.0;
6060
Eigen::VectorXd z_vec(2);
6161
z_vec << -3.0, 4.0;
6262
Eigen::RowVectorXd z_rowvec(2);
6363
z_rowvec << -3.0, 4.0;
6464
Eigen::MatrixXd zm(2, 2);
65-
x_mat << 3.0, 4.0, -1.0, 1.1;
65+
zm << 3.0, 4.0, -1.0, 1.1;
6666

6767
EXPECT_MATRIX_EQ(add(elt_multiply(x_scalar, y_scalar), z_vec),
6868
fma(x_scalar, y_scalar, z_vec));

test/unit/math/prim/fun/get_base1_lhs_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ TEST(MathMatrixPrimMat, get_base1_lhs_failing_in_26) {
77
using Eigen::Matrix;
88
using stan::math::get_base1_lhs;
99
Matrix<double, Dynamic, Dynamic> y(2, 3);
10+
y << 1, 2, 3, 4, 5, 6;
11+
1012
EXPECT_THROW(get_base1_lhs(y, 3, 1, "y", 2), std::exception);
1113
EXPECT_THROW(get_base1_lhs(y, 1, 4, "y", 2), std::exception);
1214
for (int i = 1; i <= 2; ++i)

test/unit/math/prim/prob/multi_normal_prec_rng_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ TEST(ProbDistributionsMultiNormalPrec, vectorized) {
1414
Eigen::RowVectorXd mu_t(3);
1515
std::vector<Eigen::VectorXd> vec_mu(2);
1616
std::vector<Eigen::RowVectorXd> vec_mu_t(2);
17+
mu << -1.0, 2.0, 4.0;
1718
vec_mu[0] = mu;
1819
vec_mu_t[0] = mu;
1920
mu << 2.0, -1.0, 4.0;

test/unit/math/rev/fun/scalar_seq_view_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,28 @@ void expect_scalar_seq_view_adjoints(const C& v) {
8282

8383
TEST(MathMetaRev, ScalarSeqViewVectorVar) {
8484
using stan::math::var;
85-
Eigen::Matrix<var, -1, 1> A = Eigen::VectorXd(4);
85+
Eigen::Matrix<var, -1, 1> A = Eigen::VectorXd::Ones(4);
8686
expect_scalar_seq_view_value(A);
8787
expect_scalar_seq_view_adjoints(A);
8888
}
8989

9090
TEST(MathMetaRev, ScalarSeqViewRowVectorVar) {
9191
using stan::math::var;
92-
Eigen::Matrix<var, 1, -1> A = Eigen::RowVectorXd(4);
92+
Eigen::Matrix<var, 1, -1> A = Eigen::RowVectorXd::Ones(4);
9393
expect_scalar_seq_view_value(A);
9494
expect_scalar_seq_view_adjoints(A);
9595
}
9696

9797
TEST(MathMetaRev, VarScalarSeqViewVector) {
9898
using stan::math::var_value;
99-
var_value<Eigen::Matrix<double, -1, 1>> A = Eigen::VectorXd(4);
99+
var_value<Eigen::Matrix<double, -1, 1>> A = Eigen::VectorXd::Ones(4);
100100
expect_scalar_seq_view_value(A);
101101
expect_scalar_seq_view_adjoints(A);
102102
}
103103

104104
TEST(MathMetaRev, VarScalarSeqViewRowVector) {
105105
using stan::math::var_value;
106-
var_value<Eigen::Matrix<double, 1, -1>> A = Eigen::RowVectorXd(4);
106+
var_value<Eigen::Matrix<double, 1, -1>> A = Eigen::RowVectorXd::Ones(4);
107107
expect_scalar_seq_view_value(A);
108108
expect_scalar_seq_view_adjoints(A);
109109
}

0 commit comments

Comments
 (0)