|
3 | 3 | #include <stan/math/mix.hpp> |
4 | 4 | #include <test/unit/math/rev/fun/util.hpp> |
5 | 5 | #include <test/unit/math/laplace/laplace_utility.hpp> |
6 | | -#include <test/unit/math/laplace/roach_data/mu_bad.hpp> |
7 | | -#include <test/unit/math/laplace/roach_data/sigma_bad.hpp> |
8 | | -#include <test/unit/math/laplace/roach_data/y_bad.hpp> |
9 | | -#include <test/unit/math/laplace/roach_data/mu.hpp> |
10 | 6 | #include <test/unit/math/laplace/roach_data/sigmaz.hpp> |
11 | 7 | #include <test/unit/math/laplace/roach_data/y.hpp> |
| 8 | +#include <test/unit/math/laplace/csv_reader.hpp> |
12 | 9 |
|
13 | 10 | #include <gtest/gtest.h> |
14 | 11 | #include <iostream> |
@@ -79,22 +76,20 @@ struct cov_fun_functor { |
79 | 76 | TEST(WriteArrayBodySimple, ExceededIteration) { |
80 | 77 | stan::test::relative_tolerance rel_tol(5e-2); |
81 | 78 | const double integrate_1d_reltol = 1e-8; |
82 | | - auto&& mu_bad_raw = stan::test::laplace::roach::mu_bad_raw; |
83 | | - Eigen::Map<const Eigen::VectorXd> mu_bad(mu_bad_raw.data(), |
84 | | - mu_bad_raw.size()); |
85 | | - auto&& sigma_bad_raw = stan::test::laplace::roach::sigma_bad_raw; |
86 | | - Eigen::Map<const Eigen::VectorXd> sigma_bad(sigma_bad_raw.data(), |
87 | | - sigma_bad_raw.size()); |
88 | | - auto&& y_bad_raw = stan::test::laplace::roach::y_bad_raw; |
89 | | - Eigen::Map<const Eigen::Matrix<int, -1, 1>> y_bad(y_bad_raw.data(), |
90 | | - y_bad_raw.size()); |
91 | | - const int num_samples = mu_bad.cols(); |
92 | | - const int N = mu_bad.rows(); |
| 79 | + auto mu_samples = stan::math::test::laplace::read_matrix_csv( |
| 80 | + "./test/unit/math/laplace/roach_data/mu_bad.csv"); |
| 81 | + auto sigmaz_samples = stan::math::test::laplace::read_matrix_csv( |
| 82 | + "./test/unit/math/laplace/roach_data/sigma_bad.csv"); |
| 83 | + auto y_samples_dbl = stan::math::test::laplace::read_matrix_csv( |
| 84 | + "./test/unit/math/laplace/roach_data/y_bad.csv"); |
| 85 | + auto y_samples = y_samples_dbl.cast<int>(); |
| 86 | + const int num_samples = mu_samples.cols(); |
| 87 | + const int N = mu_samples.rows(); |
93 | 88 | std::ostream* pstream = nullptr; |
94 | 89 | for (int i = 1; i <= N; ++i) { |
95 | | - auto y = y_bad(i - 1); |
96 | | - auto mu = mu_bad(i - 1); |
97 | | - auto sigmaz = sigma_bad(i - 1); |
| 90 | + auto y = y_samples(i - 1, 0); |
| 91 | + auto mu = mu_samples(i - 1, 0); |
| 92 | + auto sigmaz = sigmaz_samples(i - 1, 0); |
98 | 93 | double ll_laplace_val{0}; |
99 | 94 | try { |
100 | 95 | ll_laplace_val = stan::math::laplace_marginal( |
@@ -129,15 +124,10 @@ TEST(WriteArrayBodySimple, ExceededIteration) { |
129 | 124 | TEST(WriteArrayBodySimple, ExecutesBodyWithHardcodedData) { |
130 | 125 | stan::test::relative_tolerance rel_tol(5e-1); |
131 | 126 | const double integrate_1d_reltol = 1e-8; |
132 | | - auto&& y = stan::test::laplace::roach::y; |
133 | | - auto&& sigmaz_samples = stan::test::laplace::roach::sigmaz; |
134 | | - auto&& mu_raw = stan::test::laplace::roach::mu_raw; |
135 | | - std::size_t mu_cols = mu_raw.size() / y.size(); |
136 | | - Eigen::MatrixXd mu_samples(y.size(), mu_cols); |
137 | | - for (std::size_t i = 0; i < y.size(); ++i) { |
138 | | - mu_samples.row(i) = Eigen::Map<const Eigen::RowVectorXd>( |
139 | | - mu_raw.data() + i * mu_cols, mu_cols); |
140 | | - } |
| 127 | + auto&& y = stan::math::test::roaches::y; |
| 128 | + auto&& sigmaz_samples = stan::math::test::roaches::sigmaz; |
| 129 | + auto mu_samples = stan::math::test::laplace::read_matrix_csv( |
| 130 | + "./test/unit/math/laplace/roach_data/mu.csv"); |
141 | 131 | const int num_samples = mu_samples.cols(); |
142 | 132 | const int N = mu_samples.rows(); |
143 | 133 | std::ostream* pstream = nullptr; |
|
0 commit comments