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

expose_functions() method of CmdStanModel fails with mysterious error message #830

Closed
ksvanhorn opened this issue Aug 22, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@ksvanhorn
Copy link

Describe the bug
Calling model$expose_functions() with a CmdStanModel object results in the error message

Error in function_env$external && cmdstan_version() < "2.32" :
  invalid 'x' type in 'x && y'

To Reproduce

  1. Create a model object m.
  2. m$expose_functions()

Expected behavior
Either expose the functions or give an informative error message.

Operating system
macOS Ventura 13.4

CmdStanR version number
0.6.0.9000

Additional context
cmdstan_version() returns 2.31.0, so there should be an error message printed here. Investigating with the debugger, I find that function_env only has one name in it, compiled.

@ksvanhorn ksvanhorn added the bug Something isn't working label Aug 22, 2023
@jgabry
Copy link
Member

jgabry commented Aug 22, 2023

I think this is the same issue as #784, where the error only occurs if the executable already exists, not anytime you create a model object. But your To Reproduce section seems to imply this always happens for you, is that right?

Does this example work?

stan_file <- write_stan_file(
 "
 functions {
   real a_plus_b(real a, real b) {
     return a + b;
   }
 }
 parameters {
   real x;
 }
 model {
   x ~ std_normal();
 }
 "
)
mod <- cmdstan_model(stan_file)
mod$expose_functions()
mod$functions$a_plus_b(1, 2)

For me this works fine. But if the executable already exists and then I create a model object I get the error you're mentioning (which we need to fix).

@ksvanhorn
Copy link
Author

Ah, no, I didn't check for that. Your example does in fact work for me. You're right, the model I was using was already compiled.

@andrjohns
Copy link
Collaborator

Closed by #831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants