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

pass 'data' to parse_data() (fixes bug if data is named "i") #655

Merged
merged 3 commits into from Jul 7, 2019

Conversation

jgabry
Copy link
Member

@jgabry jgabry commented Jun 7, 2019

fixes #654

Summary:

Data named i was overwritten by RStan.

Intended Effect

Give parse_data() a data argument instead of using with(data, ...) in sampling(). And then use mget() instead of dynGet() inside of parse_data(). This avoid overwriting i, but it's unclear why it was being overwritten. See comments in #654.

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): Columbia University

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@jgabry jgabry requested a review from bgoodri June 7, 2019 23:33
@jgabry jgabry changed the title pass 'data' to parse_data() (fixes bug if data is named "i" pass 'data' to parse_data() (fixes bug if data is named "i") Jun 7, 2019
@bgoodri
Copy link
Contributor

bgoodri commented Jun 27, 2019 via email

@jgabry
Copy link
Member Author

jgabry commented Jun 27, 2019

I assume so, but not it's not clear where. parse_data is called from the sampling() method which doesn't have an explicit loop over i. And neither does the stan function when it calls sampling.

@jgabry
Copy link
Member Author

jgabry commented Jun 27, 2019

If I change parse_data to do the same thing in a loop that sapply was doing (and also use int instead of i to index) then it seems to be ok:

# current method: stuff$i will have wrong value
  stuff <- sapply(objects, simplify = FALSE, FUN = dynGet, 
                  inherits = FALSE, ifnotfound = NULL)
# stuff$i has correct value
  for (int in seq_along(objects)) {
   stuff[[objects[int]]] <- dynGet(objects[int], inherits = FALSE, ifnotfound = NULL)
  }

@bgoodri
Copy link
Contributor

bgoodri commented Jun 27, 2019 via email

@bgoodri bgoodri merged commit 8caa872 into develop Jul 7, 2019
@bgoodri bgoodri deleted the fix-parsing-data branch July 7, 2019 17:39
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.

data named “i” is overwritten by rstan
2 participants