Skip to content

Commit b30823d

Browse files
committed
remove .csv files for .hpp files
1 parent d86fa69 commit b30823d

12 files changed

Lines changed: 457 additions & 485 deletions

File tree

test/unit/math/laplace/aki_ex_test.cpp

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
#include <stan/math/mix.hpp>
44
#include <test/unit/math/rev/fun/util.hpp>
55
#include <test/unit/math/laplace/laplace_utility.hpp>
6-
#include <test/unit/math/laplace/roach_data/y.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>
710
#include <test/unit/math/laplace/roach_data/sigmaz.hpp>
8-
#include <test/unit/math/laplace/csv_reader.hpp>
11+
#include <test/unit/math/laplace/roach_data/y.hpp>
912

1013
#include <gtest/gtest.h>
1114
#include <iostream>
@@ -76,21 +79,19 @@ struct cov_fun_functor {
7679
TEST(WriteArrayBodySimple, ExceededIteration) {
7780
stan::test::relative_tolerance rel_tol(5e-2);
7881
const double integrate_1d_reltol = 1e-8;
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();
82+
auto&& mu_bad_raw = stan::test::laplace::roach::mu_bad_raw;
83+
Eigen::Map<const Eigen::VectorXd> mu_bad(mu_bad_raw.data(), mu_bad_raw.size());
84+
auto&& sigma_bad_raw = stan::test::laplace::roach::sigma_bad_raw;
85+
Eigen::Map<const Eigen::VectorXd> sigma_bad(sigma_bad_raw.data(), sigma_bad_raw.size());
86+
auto&& y_bad_raw = stan::test::laplace::roach::y_bad_raw;
87+
Eigen::Map<const Eigen::Matrix<int, -1, 1>> y_bad(y_bad_raw.data(), y_bad_raw.size());
88+
const int num_samples = mu_bad.cols();
89+
const int N = mu_bad.rows();
8890
std::ostream* pstream = nullptr;
8991
for (int i = 1; i <= N; ++i) {
90-
auto y = y_samples(i - 1, 0);
91-
auto mu = mu_samples(i - 1, 0);
92-
auto sigmaz = sigmaz_samples(i - 1, 0);
93-
92+
auto y = y_bad(i - 1);
93+
auto mu = mu_bad(i - 1);
94+
auto sigmaz = sigma_bad(i - 1);
9495
double ll_laplace_val{0};
9596
try {
9697
ll_laplace_val = stan::math::laplace_marginal(
@@ -125,10 +126,15 @@ TEST(WriteArrayBodySimple, ExceededIteration) {
125126
TEST(WriteArrayBodySimple, ExecutesBodyWithHardcodedData) {
126127
stan::test::relative_tolerance rel_tol(5e-1);
127128
const double integrate_1d_reltol = 1e-8;
128-
auto&& y = stan::math::test::roaches::y;
129-
auto&& sigmaz_samples = stan::math::test::roaches::sigmaz;
130-
auto mu_samples = stan::math::test::laplace::read_matrix_csv(
131-
"./test/unit/math/laplace/roach_data/mu.csv");
129+
auto&& y = stan::test::laplace::roach::y;
130+
auto&& sigmaz_samples = stan::test::laplace::roach::sigmaz;
131+
auto&& mu_raw = stan::test::laplace::roach::mu_raw;
132+
std::size_t mu_cols = mu_raw.size() / y.size();
133+
Eigen::MatrixXd mu_samples(y.size(), mu_cols);
134+
for (std::size_t i = 0; i < y.size(); ++i) {
135+
mu_samples.row(i) = Eigen::Map<const Eigen::RowVectorXd>(
136+
mu_raw.data() + i * mu_cols, mu_cols);
137+
}
132138
const int num_samples = mu_samples.cols();
133139
const int N = mu_samples.rows();
134140
std::ostream* pstream = nullptr;

test/unit/math/laplace/csv_reader.hpp

Lines changed: 0 additions & 66 deletions
This file was deleted.

test/unit/math/laplace/motorcycle_gp/x_vec.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#ifndef STAN_TEST_UNIT_MIX_LAPLACE_MOTORCYCLE_GP_HPP
22
#define STAN_TEST_UNIT_MIX_LAPLACE_MOTORCYCLE_GP_HPP
3+
#include <stan/math/prim/fun/Eigen.hpp>
4+
#include <vector>
35
namespace stan {
46
namespace test {
57
namespace laplace {
Lines changed: 269 additions & 262 deletions
Large diffs are not rendered by default.

test/unit/math/laplace/roach_data/mu_bad.csv

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#pragma once
2+
#include <vector>
3+
namespace stan::test::laplace::roach {
4+
5+
static const auto mu_bad_raw = std::vector<double>{
6+
7.80752,
7+
7.51451,
8+
7.5743,
9+
7.70856,
10+
7.77522,
11+
7.72442,
12+
7.68076,
13+
7.76911,
14+
7.99381,
15+
7.65103,
16+
7.84669,
17+
7.5935,
18+
8.43441,
19+
8.45228,
20+
1.5154,
21+
-0.36275,
22+
1.88855,
23+
2.32427,
24+
0.457985,
25+
1.72253,
26+
0.133349,
27+
2.87951,
28+
2.72827,
29+
4.4408,
30+
-0.51603,
31+
3.71262,
32+
2.09379,
33+
1.89307,
34+
0.247243,
35+
-0.822329,
36+
-0.734069,
37+
0.671064,
38+
1.42225,
39+
3.50831,
40+
1.28212,
41+
3.68347,
42+
1.50733,
43+
1.5619,
44+
0.0129277,
45+
0.0129277,
46+
1.41688,
47+
2.6884,
48+
2.83447,
49+
5.34951,
50+
-0.281801};
51+
}
52+

test/unit/math/laplace/roach_data/sigma_bad.csv

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
#include <vector>
3+
namespace stan::test::laplace::roach {
4+
5+
static const auto sigma_bad_raw = std::vector<double>{
6+
2.41983,
7+
2.31403,
8+
2.34082,
9+
2.38011,
10+
2.35559,
11+
2.30412,
12+
2.27998,
13+
2.26287,
14+
2.31751,
15+
2.33675,
16+
2.26045,
17+
2.33043,
18+
2.44247,
19+
2.31163,
20+
2.12269,
21+
1.93225,
22+
2.01201,
23+
2.05116,
24+
2.02358,
25+
2.14954,
26+
2.04622,
27+
1.86912,
28+
1.942,
29+
2.23927,
30+
2.03573,
31+
2.01325,
32+
1.93353,
33+
2.18344,
34+
1.85735,
35+
1.99109,
36+
2.10951,
37+
2.15974,
38+
1.9316,
39+
2.05804,
40+
2.05804,
41+
2.04376,
42+
2.04625,
43+
2.00721,
44+
1.81805,
45+
1.81805,
46+
2.05462,
47+
2.07048,
48+
1.94824,
49+
1.83815,
50+
2.14474};
51+
52+
}
53+

test/unit/math/laplace/roach_data/sigmaz.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
#pragma once
33
#include <stan/math/prim/fun/Eigen.hpp>
4-
namespace stan::math::test::roaches {
4+
namespace stan::test::laplace::roach {
5+
56

67
static const Eigen::Matrix<double, -1, -1> sigmaz{
78
{{2.03651, 1.97969, 2.01858, 2.05345, 2.01933, 1.8819, 1.87645, 2.12067,

test/unit/math/laplace/roach_data/y.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22
#include <stan/math/prim/fun/Eigen.hpp>
3-
namespace stan::math::test::roaches {
3+
namespace stan::test::laplace::roach {
44

5-
static std::vector<int> y{
5+
6+
static const std::vector<int> y{
67
153, 127, 7, 7, 0, 0, 73, 24, 2, 2, 0, 21, 0, 179, 136, 104,
78
2, 5, 1, 203, 32, 1, 135, 59, 29, 120, 44, 1, 2, 193, 13, 37,
89
2, 0, 3, 0, 0, 15, 11, 19, 0, 19, 4, 122, 48, 0, 0, 3,

0 commit comments

Comments
 (0)