Skip to content

Bugfix - Deep copy method/function environments #709

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

Merged
merged 3 commits into from
Nov 5, 2022
Merged

Bugfix - Deep copy method/function environments #709

merged 3 commits into from
Nov 5, 2022

Conversation

andrjohns
Copy link
Collaborator

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

There was a bug with the model methods and exposed functions wherein running init_model_methods() on a CmdStanFit object would overwrite the model methods from all CmdStanFit objects that came from the same CmdStanModel.

This was because the environment was being passed by reference from the CmdStanModel object when initialising each CmdStanFit, so every fit object was pointing to the same environment.

This PR updates the initialisation to create a new environment and copy the contents, as well as adding a test to check for this in the future

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):
Andrew Johnson

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

@rok-cesnovar
Copy link
Member

Thanks! Merge once you get the unit tests to pass.

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2022

Codecov Report

Merging #709 (6d0105b) into master (f8f6321) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #709      +/-   ##
==========================================
+ Coverage   88.44%   88.46%   +0.01%     
==========================================
  Files          12       12              
  Lines        4017     4021       +4     
==========================================
+ Hits         3553     3557       +4     
  Misses        464      464              
Impacted Files Coverage Δ
R/fit.R 97.47% <100.00%> (+0.03%) ⬆️
R/utils.R 73.40% <100.00%> (-0.12%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@andrjohns andrjohns merged commit ecb7d89 into stan-dev:master Nov 5, 2022
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.

3 participants