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

Integer detection fails when resulting array used in output #106

Closed
richfitz opened this issue Feb 27, 2018 · 3 comments
Closed

Integer detection fails when resulting array used in output #106

richfitz opened this issue Feb 27, 2018 · 3 comments
Labels
bug

Comments

@richfitz
Copy link
Member

@richfitz richfitz commented Feb 27, 2018

odin::odin({
  update(x) <- 1
  initial(x) <- 1
 
  y[] <- user()
  dim(y) <- user()
  v <- user()

  z <- y[step - v]
  output(z) <- z # comment this line out and it compiles
})
@richfitz
Copy link
Member Author

@richfitz richfitz commented Mar 2, 2018

Integer detection also failing when input is user?

via Joel:

sprayChemical <- user()
# later
rho_IRS2 <- rhovec2[sprayChemical]

odin_model_emanators_IRS.c:1202:77: error: array subscript is not an integer
   odin_model_emanators_IRS_p->rho_IRS2 = odin_model_emanators_IRS_p->rhovec2[odin_model_emanators_IRS_p->sc - 1];
@richfitz richfitz added the bug label Mar 2, 2018
@jhellewell14
Copy link

@jhellewell14 jhellewell14 commented Mar 2, 2018

sc2 <- 1
rho_IRS1 <- rhovec1[sc2]
# gives 
odin_model_emanators_IRS.c:1210:77: error: array subscript is not an integer
   odin_model_emanators_IRS_p->rho_IRS1 = odin_model_emanators_IRS_p->rhovec1[odin_model_emanators_IRS_p->sc2 - 1];

From compiling this model: https://github.com/mrc-ide/deterministic-malaria-model/blob/joel/inst/extdata/odin_model_emanators_IRS.R

@richfitz
Copy link
Member Author

@richfitz richfitz commented Mar 15, 2019

Solution:

odin({
  update(x) <- 1
  initial(x) <- 1
 
  y[] <- user()
  dim(y) <- user()
  v <- user(integer = TRUE)

  z <- y[step - v]
  output(z) <- z # comment this line out and it compiles
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.