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
Feature/issue 422 clean standalone functions #459
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…mpile, that should go away; and 2) the RNG must get copied somewhere since it doesn't advance properly (repeat calls with same RNG get same value)... at worst one could create new RNG with random seed every time, at best I could make sure no copies occur.
This version of expose_stan_functions works with stan-dev/stan branch "maintenance/issue-2401-remove-unnecessary-standalone-code-try-2". For the moment the rng/stream must be passed explicitely, but next step is to make default global objects. To check it out make a foo.stan like so: functions { real f_rng(real mu) { real x = normal_rng(mu, 1); return x; } } Then in R run: library(rstan) rstan::expose_stan_functions('foo.stan', cacheDir='.') o <- get_stream() rng <- get_rng(3) f_rng(3.3, rng, o) f_rng(3.3, rng, o) f_rng(3.3, rng, o) f_rng(3.3, rng, o) f_rng(3.3, rng, o) Each call with the same RNG should return a new draw. Re-initializing the RNG with the same seed should restart the sequence. Functions that print will print via Rcpp::rcout.
Can one of the admins verify this patch? |
@bgoodri just figured out how to get rid of the warnings about rstan::RNG and rstan::OUT, pushed that. |
Here's the install_SteanHeaders.R for it:
|
2 tasks
Is this going in 2.18? |
Yes
…On Sun, Feb 18, 2018 at 7:42 AM, Allen Riddell ***@***.***> wrote:
Is this going in 2.18?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#459 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADOrqnUxW7hDAy29trdmJEuQNZpI_9aHks5tWBq6gaJpZM4P8OP_>
.
|
No idea if this already made it in or not but if you need help finalizing it ping me. @bgoodri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Remove most code-grepping from rstan::expose_stan_functions, hide generated code in namespace and call it via wrapper. There are warnings I'm not sure how to get rid of at the moment about get_rng and get_stream, we should fix those before merging.
Intended Effect:
This version of expose_stan_functions works with stan-dev/stan branch
"maintenance/issue-2401-remove-unnecessary-standalone-code-try-2". For
the moment the rng/stream must be passed explicitely, but next step is
to make default global objects. To check it out make a foo.stan like
so:
How to Verify:
Use with the `` stan-dev/stan branch. Make sure the code above runs as expected. Also test a .stan function that prints output via print.
Side Effects:
None?
Documentation:
I don't know where we document expose_stan_functions but we should add documentation about the get_stream and get_rng functions there. Should also doc rstan::RNG and rstan::OUT. I haven't figured out how to inject those as the default arguments to the R wrappers for the exposed Stan functions yet.
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: