Skip to content

Commit 3a4f55b

Browse files
committed
updated for stan branch bugfix/3301-stan-csv-reader
1 parent 4a805d0 commit 3a4f55b

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

src/cmdstan/command_helper.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,19 @@ void parse_stan_csv(const std::string &fname,
284284
std::stringstream msg;
285285
// parse CSV contents
286286
std::ifstream stream = file::safe_open(fname);
287-
stan::io::stan_csv_reader::read_metadata(stream, fitted_params.metadata,
288-
&msg);
289-
if (!stan::io::stan_csv_reader::read_header(stream, fitted_params.header,
290-
&msg, false)) {
287+
stan::io::stan_csv_reader::read_metadata(stream, fitted_params.metadata);
288+
if (!stan::io::stan_csv_reader::read_header(stream,
289+
fitted_params.header,
290+
false)) {
291291
msg << "Error reading fitted param names from sample csv file \"" << fname
292292
<< "\"" << std::endl;
293293
throw std::invalid_argument(msg.str());
294294
}
295-
stan::io::stan_csv_reader::read_adaptation(stream, fitted_params.adaptation,
296-
&msg);
295+
stan::io::stan_csv_reader::read_adaptation(stream, fitted_params.adaptation);
297296
fitted_params.timing.warmup = 0;
298297
fitted_params.timing.sampling = 0;
299298
stan::io::stan_csv_reader::read_samples(stream, fitted_params.samples,
300-
fitted_params.timing, &msg);
299+
fitted_params.timing);
301300
stream.close();
302301
// compute offset, size of parameters block
303302
col_offset = 0;

src/test/interface/generated_quantities_test.cpp

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,22 @@ TEST_F(CmdStan, generate_quantities_warmup) {
183183

184184
std::ifstream fp_stream(fp_path.c_str());
185185
stan::io::stan_csv fitted_params;
186-
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata,
187-
&msg);
188-
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header, &msg,
189-
false);
186+
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata);
187+
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header,
188+
false);
190189
stan::io::stan_csv_reader::read_samples(fp_stream, fitted_params.samples,
191-
fitted_params.timing, &msg);
190+
fitted_params.timing);
192191
fp_stream.close();
193192

194193
std::ifstream gq_stream(gq_output_path.c_str());
195194
stan::io::stan_csv gq_output;
196195
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
197-
gq_output.timing, &msg);
198-
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata, &msg);
199-
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header, &msg,
196+
gq_output.timing);
197+
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata);
198+
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header,
200199
false);
201200
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
202-
gq_output.timing, &msg);
201+
gq_output.timing);
203202
gq_stream.close();
204203

205204
ASSERT_EQ(fitted_params.samples.rows(), gq_output.samples.rows());
@@ -222,23 +221,22 @@ TEST_F(CmdStan, generate_quantities_after_optimization) {
222221

223222
std::ifstream fp_stream(fp_path.c_str());
224223
stan::io::stan_csv fitted_params;
225-
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata,
226-
&msg);
227-
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header, &msg,
224+
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata);
225+
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header,
228226
false);
229227
stan::io::stan_csv_reader::read_samples(fp_stream, fitted_params.samples,
230-
fitted_params.timing, &msg);
228+
fitted_params.timing);
231229
fp_stream.close();
232230

233231
std::ifstream gq_stream(gq_output_path.c_str());
234232
stan::io::stan_csv gq_output;
235233
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
236-
gq_output.timing, &msg);
237-
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata, &msg);
238-
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header, &msg,
234+
gq_output.timing);
235+
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata);
236+
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header,
239237
false);
240238
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
241-
gq_output.timing, &msg);
239+
gq_output.timing);
242240
gq_stream.close();
243241

244242
ASSERT_EQ(fitted_params.samples.rows(), gq_output.samples.rows());
@@ -261,23 +259,22 @@ TEST_F(CmdStan, generate_quantities_after_vb) {
261259

262260
std::ifstream fp_stream(fp_path.c_str());
263261
stan::io::stan_csv fitted_params;
264-
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata,
265-
&msg);
266-
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header, &msg,
262+
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata);
263+
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header,
267264
false);
268265
stan::io::stan_csv_reader::read_samples(fp_stream, fitted_params.samples,
269-
fitted_params.timing, &msg);
266+
fitted_params.timing);
270267
fp_stream.close();
271268

272269
std::ifstream gq_stream(gq_output_path.c_str());
273270
stan::io::stan_csv gq_output;
274271
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
275-
gq_output.timing, &msg);
276-
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata, &msg);
277-
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header, &msg,
272+
gq_output.timing);
273+
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata);
274+
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header,
278275
false);
279276
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
280-
gq_output.timing, &msg);
277+
gq_output.timing);
281278
gq_stream.close();
282279

283280
ASSERT_EQ(fitted_params.samples.rows(), gq_output.samples.rows());
@@ -300,23 +297,22 @@ TEST_F(CmdStan, generate_quantities_thin) {
300297

301298
std::ifstream fp_stream(fp_path.c_str());
302299
stan::io::stan_csv fitted_params;
303-
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata,
304-
&msg);
305-
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header, &msg,
300+
stan::io::stan_csv_reader::read_metadata(fp_stream, fitted_params.metadata);
301+
stan::io::stan_csv_reader::read_header(fp_stream, fitted_params.header,
306302
false);
307303
stan::io::stan_csv_reader::read_samples(fp_stream, fitted_params.samples,
308-
fitted_params.timing, &msg);
304+
fitted_params.timing);
309305
fp_stream.close();
310306

311307
std::ifstream gq_stream(gq_output_path.c_str());
312308
stan::io::stan_csv gq_output;
313309
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
314-
gq_output.timing, &msg);
315-
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata, &msg);
316-
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header, &msg,
310+
gq_output.timing);
311+
stan::io::stan_csv_reader::read_metadata(gq_stream, gq_output.metadata);
312+
stan::io::stan_csv_reader::read_header(gq_stream, gq_output.header,
317313
false);
318314
stan::io::stan_csv_reader::read_samples(gq_stream, gq_output.samples,
319-
gq_output.timing, &msg);
315+
gq_output.timing);
320316
gq_stream.close();
321317

322318
ASSERT_EQ(fitted_params.samples.rows(), gq_output.samples.rows());

src/test/interface/variational_output_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TEST_F(CmdStan, variational_default) {
5050

5151
stan::mcmc::chains<> chains = parse_output_file();
5252
ASSERT_EQ(1, chains.num_chains());
53-
ASSERT_EQ(1001, chains.num_samples());
53+
ASSERT_EQ(1000, chains.num_samples());
5454
}
5555

5656
TEST_F(CmdStan, variational_meanfield) {
@@ -61,7 +61,7 @@ TEST_F(CmdStan, variational_meanfield) {
6161

6262
stan::mcmc::chains<> chains = parse_output_file();
6363
ASSERT_EQ(1, chains.num_chains());
64-
ASSERT_EQ(1001, chains.num_samples());
64+
ASSERT_EQ(1000, chains.num_samples());
6565
}
6666

6767
TEST_F(CmdStan, variational_fullrank) {
@@ -72,5 +72,5 @@ TEST_F(CmdStan, variational_fullrank) {
7272

7373
stan::mcmc::chains<> chains = parse_output_file();
7474
ASSERT_EQ(1, chains.num_chains());
75-
ASSERT_EQ(1001, chains.num_samples());
75+
ASSERT_EQ(1000, chains.num_samples());
7676
}

0 commit comments

Comments
 (0)