Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rstan/rstan/R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,10 @@ parse_data <- function(cppcode) {
cppcode[private:public])
# get them from the calling environment
objects <- objects[nzchar(trimws(objects))]
# Remove model internal name underscores in case of Eigen::Maps
objects = gsub("([0-9A-Za-z_]+)__", "\\1", objects)
# Remove any bad regex matches that found the end of an Eigen::Map.
objects = objects[suppressWarnings(is.na(as.numeric(objects)))]
Comment thread
SteveBronder marked this conversation as resolved.
Outdated
stuff <- list()
for (int in seq_along(objects)) {
stuff[[objects[int]]] <- dynGet(objects[int], inherits = FALSE, ifnotfound = NULL)
Expand Down
12 changes: 6 additions & 6 deletions rstan/rstan/inst/include/rstan/stan_fit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,12 @@ int command(stan_args& args, Model& model, Rcpp::List& holder,
"model that has no parameters.");
int refresh = args.get_refresh();
unsigned int id = args.get_chain_id();

std::ostream nullout(nullptr);
std::ostream& c_out = refresh ? Rcpp::Rcout : nullout;
std::ostream& c_err = refresh ? rstan::io::rcerr : nullout;

stan::callbacks::stream_logger_with_chain_id
stan::callbacks::stream_logger_with_chain_id
logger(c_out, c_out, c_out, c_err, c_err, id);

R_CheckUserInterrupt_Functor interrupt;
Expand Down Expand Up @@ -1016,7 +1016,7 @@ class stan_fit {
get_all_flatnames(names_oi_, dims_oi_, fnames_oi_, true);
// get_all_indices_col2row(dims_, midx_for_col2row);
}

stan_fit(SEXP data, SEXP seed, SEXP cxxf) :
data_(data),
model_(data_, Rcpp::as<boost::uint32_t>(seed), &rstan::io::rcout),
Expand Down Expand Up @@ -1221,15 +1221,15 @@ class stan_fit {
return __sexp_result;
END_RCPP
}

SEXP standalone_gqs(SEXP pars, SEXP seed) {
BEGIN_RCPP
Rcpp::List holder;

R_CheckUserInterrupt_Functor interrupt;
stan::callbacks::stream_logger logger(Rcpp::Rcout, Rcpp::Rcout, Rcpp::Rcout,
rstan::io::rcerr, rstan::io::rcerr);

const Eigen::Map<Eigen::MatrixXd> draws(Rcpp::as<Eigen::Map<Eigen::MatrixXd> >(pars));

std::unique_ptr<rstan_sample_writer> sample_writer_ptr;
Expand All @@ -1248,7 +1248,7 @@ class stan_fit {
gq_size,
draws.rows(), 0,
gq_idx));

int ret = stan::services::error_codes::CONFIG;
ret = stan::services::standalone_generate(model_, draws,
Rcpp::as<unsigned int>(seed), interrupt, logger, *sample_writer_ptr);
Expand Down