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

Fix error while generating odin model #134

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Fix error while generating odin model #134

merged 2 commits into from
Dec 16, 2024

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented Dec 16, 2024

This PR fixes the error seen by Debbie - it's not terribly obvious at first:

      nm <- deparse(e[[1L]])
      ...
      if (nm %in% c("length", "dim") && length(e) == 2 && is.symbol(e[[2]])) {

this produces a length 2 logical where deparse returns a length 2 vector. We assume it won't do that because normally we use it on sensible calls. However we also use this in the generation phase where we just want to peek into the rhs to see which index variables (i, j, k etc) we use and by that time we've rewritten binomial draws as

OdinStochasticCall(sample = "binomial", mean = S_leave[i, j, 
    k] * (S_rates[i, j, k, 1]/S_leave_rate[i, j, k]))(S_leave[i, 
    j, k], S_rates[i, j, k, 1]/S_leave_rate[i, j, k])

but here the "function name" (the thing called), is OdinStochasticCall(sample = "binomial", mean = S_leave[i, j, k] * (S_rates[i, j, k, 1]/S_leave_rate[i, j, k])) which flows onto two lines in deparse...

@richfitz richfitz changed the title Mrc 6118 Fix error while generating odin model Dec 16, 2024
@richfitz richfitz marked this pull request as ready for review December 16, 2024 09:52
@richfitz richfitz requested a review from weshinsley December 16, 2024 09:52
@weshinsley weshinsley merged commit 250dc81 into main Dec 16, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants