Skip to content

Commit 48d79e7

Browse files
committed
fix opencl normal_lccdf test copy / paste error
1 parent 5069528 commit 48d79e7

1 file changed

Lines changed: 58 additions & 105 deletions

File tree

test/unit/math/opencl/rev/normal_lccdf_test.cpp

Lines changed: 58 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
#include <test/unit/math/opencl/util.hpp>
66
#include <vector>
77

8-
namespace exp_mod_normal_lccdf_test {
9-
10-
TEST(ProbDistributionsDoubleExpModNormalLccdf, error_checking) {
8+
TEST(ProbDistributionsNormalLccdf, error_checking) {
119
int N = 3;
1210

1311
Eigen::VectorXd y(N);
@@ -31,13 +29,6 @@ TEST(ProbDistributionsDoubleExpModNormalLccdf, error_checking) {
3129
Eigen::VectorXd sigma_value(N);
3230
sigma_value << 0.3, 0, 0.5;
3331

34-
Eigen::VectorXd lambda(N);
35-
lambda << 0.4, 0.4, 1.4;
36-
Eigen::VectorXd lambda_size(N - 1);
37-
lambda_size << 0.3, 0.8;
38-
Eigen::VectorXd lambda_value(N);
39-
lambda_value << 0.3, 0, 0.5;
40-
4132
stan::math::matrix_cl<double> y_cl(y);
4233
stan::math::matrix_cl<double> y_size_cl(y_size);
4334
stan::math::matrix_cl<double> y_value_cl(y_value);
@@ -47,144 +38,106 @@ TEST(ProbDistributionsDoubleExpModNormalLccdf, error_checking) {
4738
stan::math::matrix_cl<double> sigma_cl(sigma);
4839
stan::math::matrix_cl<double> sigma_size_cl(sigma_size);
4940
stan::math::matrix_cl<double> sigma_value_cl(sigma_value);
50-
stan::math::matrix_cl<double> lambda_cl(lambda);
51-
stan::math::matrix_cl<double> lambda_size_cl(lambda_size);
52-
stan::math::matrix_cl<double> lambda_value_cl(lambda_value);
53-
54-
EXPECT_NO_THROW(
55-
stan::math::exp_mod_normal_lccdf(y_cl, mu_cl, sigma_cl, lambda_cl));
56-
57-
EXPECT_THROW(
58-
stan::math::exp_mod_normal_lccdf(y_size_cl, mu_cl, sigma_cl, lambda_cl),
59-
std::invalid_argument);
60-
EXPECT_THROW(
61-
stan::math::exp_mod_normal_lccdf(y_cl, mu_size_cl, sigma_cl, lambda_cl),
62-
std::invalid_argument);
63-
EXPECT_THROW(
64-
stan::math::exp_mod_normal_lccdf(y_cl, mu_cl, sigma_size_cl, lambda_cl),
65-
std::invalid_argument);
66-
EXPECT_THROW(
67-
stan::math::exp_mod_normal_lccdf(y_cl, mu_cl, sigma_cl, lambda_size_cl),
68-
std::invalid_argument);
69-
70-
EXPECT_THROW(
71-
stan::math::exp_mod_normal_lccdf(y_value_cl, mu_cl, sigma_cl, lambda_cl),
72-
std::domain_error);
73-
EXPECT_THROW(
74-
stan::math::exp_mod_normal_lccdf(y_cl, mu_value_cl, sigma_cl, lambda_cl),
75-
std::domain_error);
76-
EXPECT_THROW(
77-
stan::math::exp_mod_normal_lccdf(y_cl, mu_cl, sigma_value_cl, lambda_cl),
78-
std::domain_error);
79-
EXPECT_THROW(
80-
stan::math::exp_mod_normal_lccdf(y_cl, mu_cl, sigma_cl, lambda_value_cl),
81-
std::domain_error);
41+
42+
EXPECT_NO_THROW(stan::math::normal_lccdf(y_cl, mu_cl, sigma_cl));
43+
44+
EXPECT_THROW(stan::math::normal_lccdf(y_size_cl, mu_cl, sigma_cl),
45+
std::invalid_argument);
46+
EXPECT_THROW(stan::math::normal_lccdf(y_cl, mu_size_cl, sigma_cl),
47+
std::invalid_argument);
48+
EXPECT_THROW(stan::math::normal_lccdf(y_cl, mu_cl, sigma_size_cl),
49+
std::invalid_argument);
50+
51+
EXPECT_THROW(stan::math::normal_lccdf(y_value_cl, mu_cl, sigma_cl),
52+
std::domain_error);
53+
EXPECT_THROW(stan::math::normal_lccdf(y_cl, mu_value_cl, sigma_cl),
54+
std::domain_error);
55+
EXPECT_THROW(stan::math::normal_lccdf(y_cl, mu_cl, sigma_value_cl),
56+
std::domain_error);
8257
}
8358

84-
auto exp_mod_normal_lccdf_functor
85-
= [](const auto& y, const auto& mu, const auto& sigma, const auto& lambda) {
86-
return stan::math::exp_mod_normal_lccdf(y, mu, sigma, lambda);
59+
auto normal_lccdf_functor
60+
= [](const auto& y, const auto& mu, const auto& sigma) {
61+
return stan::math::normal_lccdf(y, mu, sigma);
8762
};
8863

89-
TEST(ProbDistributionsDoubleExpModNormalLccdf, opencl_matches_cpu_small) {
64+
TEST(ProbDistributionsNormalLccdf, opencl_matches_cpu_small) {
9065
int N = 3;
9166
int M = 2;
9267

9368
Eigen::VectorXd y(N);
94-
y << -0.3, 1.8, 1.4;
69+
y << 0.3, 0.8, 1.0;
9570
Eigen::VectorXd mu(N);
96-
mu << 0.3, 0.8, 1.0;
71+
mu << -0.3, -0.8, 1.01;
9772
Eigen::VectorXd sigma(N);
98-
sigma << 0.3, 0.8, 1.0;
99-
Eigen::VectorXd lambda(N);
100-
lambda << 0.3, 0.4, 1.1;
73+
sigma << 0.3, 0.1, 1.0;
10174

102-
stan::math::test::compare_cpu_opencl_prim_rev(exp_mod_normal_lccdf_functor, y,
103-
mu, sigma, lambda);
75+
stan::math::test::compare_cpu_opencl_prim_rev(normal_lccdf_functor, y, mu,
76+
sigma);
10477
stan::math::test::compare_cpu_opencl_prim_rev(
105-
exp_mod_normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
106-
sigma.transpose().eval(), lambda.transpose().eval());
78+
normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
79+
sigma.transpose().eval());
10780
}
10881

109-
TEST(ProbDistributionsDoubleExpModNormalLccdf,
110-
opencl_matches_cpu_small_y_pos_inf) {
82+
TEST(ProbDistributionsNormalLccdf, opencl_broadcast_y) {
11183
int N = 3;
112-
int M = 2;
11384

114-
Eigen::VectorXd y(N);
115-
y << -0.3, 1.8, INFINITY;
85+
double y_scal = 12.3;
11686
Eigen::VectorXd mu(N);
117-
mu << 0.3, 0.8, 1.0;
87+
mu << 0.5, 1.2, 1.0;
11888
Eigen::VectorXd sigma(N);
11989
sigma << 0.3, 0.8, 1.0;
120-
Eigen::VectorXd lambda(N);
121-
lambda << 0.3, 0.4, 1.1;
12290

123-
stan::math::test::compare_cpu_opencl_prim_rev(exp_mod_normal_lccdf_functor, y,
124-
mu, sigma, lambda);
125-
stan::math::test::compare_cpu_opencl_prim_rev(
126-
exp_mod_normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
127-
sigma.transpose().eval(), lambda.transpose().eval());
91+
stan::math::test::test_opencl_broadcasting_prim_rev<0>(normal_lccdf_functor,
92+
y_scal, mu, sigma);
93+
stan::math::test::test_opencl_broadcasting_prim_rev<0>(
94+
normal_lccdf_functor, y_scal, mu.transpose().eval(), sigma);
12895
}
12996

130-
TEST(ProbDistributionsDoubleExpModNormalLccdf,
131-
opencl_matches_cpu_small_y_neg_inf) {
97+
TEST(ProbDistributionsNormalLccdf, opencl_broadcast_mu) {
13298
int N = 3;
133-
int M = 2;
13499

135100
Eigen::VectorXd y(N);
136-
y << -0.3, 1.8, -INFINITY;
137-
Eigen::VectorXd mu(N);
138-
mu << 0.3, 0.8, 1.0;
101+
y << 0.3, 0.8, 1.0;
102+
double mu_scal = 12.3;
139103
Eigen::VectorXd sigma(N);
140104
sigma << 0.3, 0.8, 1.0;
141-
Eigen::VectorXd lambda(N);
142-
lambda << 0.3, 0.4, 1.1;
143105

144-
stan::math::test::compare_cpu_opencl_prim_rev(exp_mod_normal_lccdf_functor, y,
145-
mu, sigma, lambda);
146-
stan::math::test::compare_cpu_opencl_prim_rev(
147-
exp_mod_normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
148-
sigma.transpose().eval(), lambda.transpose().eval());
106+
stan::math::test::test_opencl_broadcasting_prim_rev<1>(normal_lccdf_functor,
107+
y, mu_scal, sigma);
108+
stan::math::test::test_opencl_broadcasting_prim_rev<1>(
109+
normal_lccdf_functor, y.transpose().eval(), mu_scal, sigma);
149110
}
150111

151-
TEST(ProbDistributionsDoubleExpModNormalLccdf, opencl_broadcast_y) {
112+
TEST(ProbDistributionsNormalLccdf, opencl_broadcast_sigma) {
152113
int N = 3;
153114

154-
double y_scal = 12.3;
115+
Eigen::VectorXd y(N);
116+
y << 0.3, 0.8, 1.0;
155117
Eigen::VectorXd mu(N);
156-
mu << 0.5, 1.2, 1.0;
157-
Eigen::VectorXd sigma(N);
158-
sigma << 0.3, 0.8, 1.0;
159-
Eigen::VectorXd lambda(N);
160-
lambda << 0.3, 0.4, 1.1;
118+
mu << 0.3, 0.8, 1.0;
119+
double sigma_scal = 12.3;
161120

162-
stan::math::test::test_opencl_broadcasting_prim_rev<0>(
163-
exp_mod_normal_lccdf_functor, y_scal, mu, sigma, lambda);
164-
stan::math::test::test_opencl_broadcasting_prim_rev<0>(
165-
exp_mod_normal_lccdf_functor, y_scal, mu.transpose().eval(), sigma,
166-
lambda.transpose().eval());
121+
stan::math::test::test_opencl_broadcasting_prim_rev<2>(normal_lccdf_functor,
122+
y, mu, sigma_scal);
123+
stan::math::test::test_opencl_broadcasting_prim_rev<2>(
124+
normal_lccdf_functor, y.transpose().eval(), mu, sigma_scal);
167125
}
168126

169-
TEST(ProbDistributionsDoubleExpModNormalLccdf, opencl_matches_cpu_big) {
127+
TEST(ProbDistributionsNormalLccdf, opencl_matches_cpu_big) {
170128
int N = 153;
171129

172130
Eigen::Matrix<double, Eigen::Dynamic, 1> y
173131
= Eigen::Array<double, Eigen::Dynamic, 1>::Random(N, 1).abs();
174132
Eigen::Matrix<double, Eigen::Dynamic, 1> mu
175133
= Eigen::Array<double, Eigen::Dynamic, 1>::Random(N, 1).abs();
176134
Eigen::Matrix<double, Eigen::Dynamic, 1> sigma
177-
= Eigen::Array<double, Eigen::Dynamic, 1>::Random(N, 1).abs().array()
178-
+ 0.1;
179-
Eigen::Matrix<double, Eigen::Dynamic, 1> lambda
180-
= Eigen::Array<double, Eigen::Dynamic, 1>::Random(N, 1).abs();
135+
= Eigen::Array<double, Eigen::Dynamic, 1>::Random(N, 1).abs() + 0.01;
181136

182-
stan::math::test::compare_cpu_opencl_prim_rev(exp_mod_normal_lccdf_functor, y,
183-
mu, sigma, lambda);
137+
stan::math::test::compare_cpu_opencl_prim_rev(normal_lccdf_functor, y, mu,
138+
sigma);
184139
stan::math::test::compare_cpu_opencl_prim_rev(
185-
exp_mod_normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
186-
sigma.transpose().eval(), lambda.transpose().eval());
140+
normal_lccdf_functor, y.transpose().eval(), mu.transpose().eval(),
141+
sigma.transpose().eval());
187142
}
188-
} // namespace exp_mod_normal_lccdf_test
189-
190-
#endif
143+
#endif

0 commit comments

Comments
 (0)