Fix error with off by one indexing#291
Conversation
|
There are some checks on the length of the MCMC failing. I'm not sure what the best way to resolve these are without just hacking them. The files included in I think this is worth looking at, because running cmdstan as in the manual, followed by rcmdstan gives this error. Perhaps adding an 'index_adjust' option to |
|
Thanks for reporting this. I just opened an issue (#292) about this and I'll respond more over there (so we can have the discussion in a separate issue in case this particular PR doesn't end up being the solution). |
|
@johnlees was there an issue if you dealt with it as a character? If some tests failed, those tests might need a revisit? |
|
Yes, sorry I was getting: I think changing to |
|
@rok-cesnovar An error in the test coverage, but otherwise passes. Does this fix look like what you envisioned? |
No problem at all! Its free Github instances :) Thanks for working on this! |
I think so yes. Will take a look shortly. |
|
It looks like the test coverage failure is due to the tests for |
|
Argh, yes. https://github.com/stan-dev/cmdstanr/blob/master/tests/testthat/helper-envvars-and-paths.R#L18 needs to be updated. Want to push to this PR or master @jgabry? I wont be at a computer till tomorrow morning. Can do it then. |
|
Yeah, no problem, I can fix that now. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #291 +/- ##
=======================================
Coverage 90.11% 90.11%
=======================================
Files 12 12
Lines 2419 2419
=======================================
Hits 2180 2180
Misses 239 239 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jgabry
left a comment
There was a problem hiding this comment.
@johnlees Looks good, thanks! I'm approving but will wait to merge in case @rok-cesnovar notices anything I missed.
|
Thanks @johnlees! |
Submission Checklist
Summary
There appears to be an off-by-one indexing issue in R vs C++. The default index of 0 found in the metadata is invalid for R lists which are 1-indexed. This leads to the following error, which is difficult for the user to comprehend:
The right solution to me would seem to be to convert the index into R's 1-index form, where they are used in this manner.
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):
John Lees
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: