You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reportee (@cdriveraus) provided a script which shows this by inserting a bad line at a known position in the source and showing what the compiler reports:
library(curl)
# URL of the raw file on GitHubgithub_raw_url<-"https://raw.githubusercontent.com/cdriveraus/ctsem/master/inst/stan/ctsm.stan"# Read the file content directly from the URLstanmodeltext<- readLines(curl(github_raw_url))
line_number<- c()
# Split the code into linesfor(lineiin800:1000){
# code_lines <- strsplit(stanmodeltext, "\n")[[1]]# Generate a random line of coderandom_line<-"function(x);"# Insert the random line at a random positioninsert_position<-linei#sample(length(code_lines), 1)modified_code<- append(stanmodeltext, random_line, after=insert_position-1)
# Join the modified lines back into a single stringmodified_stan_code<- paste(modified_code, collapse="\n")
Sys.sleep(.02)
error_string=try(rstan::stan_model(model_code=modified_stan_code))
#extract the string " , line xxx' from the error messageline_number<- c(line_number,as.numeric(gsub(".*line (\\d+).*", "\\1", error_string)))
plot(1:length(line_number),line_number)
abline(min(line_number),1)
}
I have modified the above code to use both cmdstanr and raw V8 calls to stancjs, and both times have gotten a plot which was a straight line:
Possible causes
Rstan does a lot of preprocessing on files before passing them to stanc3js:
Description:
It has come up several times on the forums that the line numbers reported by RStan are incorrect. The most recent is here:
https://discourse.mc-stan.org/t/stan-error-messages/34820
The reportee (@cdriveraus) provided a script which shows this by inserting a bad line at a known position in the source and showing what the compiler reports:
I have modified the above code to use both
cmdstanr
and rawV8
calls tostancjs
, and both times have gotten a plot which was a straight line:Possible causes
Rstan does a lot of preprocessing on files before passing them to stanc3js:
rstan/rstan/rstan/R/stanc.R
Lines 62 to 90 in 50c3c6f
Oddly enough, the
ctsm
file which is used in the above example contains no#includes
, so I would not expect it to be running.I believe the same preprocessing is what leads to #1067
The text was updated successfully, but these errors were encountered: