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

Allow relative path with USER_HEADER cpp_options #570

Closed
rok-cesnovar opened this issue Oct 8, 2021 · 2 comments · Fixed by #573
Closed

Allow relative path with USER_HEADER cpp_options #570

rok-cesnovar opened this issue Oct 8, 2021 · 2 comments · Fixed by #573
Labels
feature New feature or request

Comments

@rok-cesnovar
Copy link
Member

For external C++ files users can do this:

library(cmdstanr)

stan_file <- "bernoulli_external.stan"

mod <- cmdstan_model(
  stan_file,
  cpp_options = list(USER_HEADER="/home/rok/Desktop/testing/external/make_odds.hpp"),
  stanc_options = list("allow-undefined")
)
data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
fit <- mod$sample(data = data_list)

The user_header right now needs to be absolute path. We could handle that automatically.

@rok-cesnovar rok-cesnovar added the feature New feature or request label Oct 8, 2021
@rok-cesnovar
Copy link
Member Author

@jgabry what do you think if we add a user_header argument to $compile() similar to how @WardBrian did it for cmdstanpy: stan-dev/cmdstanpy#464 (comment)

I like that solution. So it would simplify the above code to:

stan_file <- "bernoulli_external.stan"

mod <- cmdstan_model(
  stan_file,
  user_header = "make_odds.hpp"
)

@jgabry
Copy link
Member

jgabry commented Oct 12, 2021

@jgabry what do you think if we add a user_header argument to $compile() similar to how @WardBrian did it for cmdstanpy

I like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants