Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USER_HEADER only works with the deprecated --allow_undefined #952

Closed
cdriveraus opened this issue Nov 30, 2020 · 0 comments
Closed

USER_HEADER only works with the deprecated --allow_undefined #952

cdriveraus opened this issue Nov 30, 2020 · 0 comments
Labels

Comments

@cdriveraus
Copy link

This thread uncovered the bug: https://discourse.mc-stan.org/t/custom-c-using-cmdstanr/19528/9
This code works, but replacing allow_undefined with allow-defined results in the custom header not being included (I believe)

library(cmdstanr)
model_code <-
"
functions {
  real my_fun(real r);
}
transformed data {
  real s = my_fun(0.0);
}
parameters {
  real y;
}
model {
  y ~ normal(0, 1);
}
"
stan_file <- write_stan_file(model_code, basename = "test.stan")
hpp_code <-
"
#include <iostream>

namespace test_model_namespace {

double my_fun(double r, std::ostream* = nullptr) {
  return r+1.0;
}

}
"
hpp_file <- "test.hpp"
write(hpp_code, file = hpp_file)
mod <- cmdstan_model(stan_file,include_paths=getwd(),
              cpp_options=list(USER_HEADER=file.path(getwd(), hpp_file)),
              stanc_options = list("allow_undefined")
)
fit <- mod$sample()
@jgabry jgabry added the bug label Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants