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

Potentially change how build handles default values #702

Merged
merged 5 commits into from
Jun 5, 2020

Conversation

corakingdon
Copy link
Collaborator

@corakingdon corakingdon commented Apr 12, 2020

The current behavior for setting default values is that the build function calls _set_defaults! on the model definition before running the model. The _set_defaults! function creates external parameters for any unconnected parameters that have default values. This means that the model definition is modified by the run function. Specifically, there will be extra parameters in the external_params list after running that weren't there before. This could cause confusion, in particular about when a user can use set_param! versus update_param! to change a parameter's value.

This PR changes the behavior of the build function such that the _set_defaults! function is called on the deepcopy of the model definition that gets stored in the created model instance, instead of on the original model definition. I think this makes for more intuitive behavior of the parameters. See the added test file here for the expected behavior.

I've marked this as draft because we should definitely discuss this.

Note: if we go with this, we'll need to check if there are cases in the models' code that use set_param/update_param at the wrong time

@corakingdon corakingdon added this to the v0.10.0 milestone Apr 12, 2020
@codecov
Copy link

codecov bot commented Apr 12, 2020

Codecov Report

Merging #702 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #702   +/-   ##
=======================================
  Coverage   80.05%   80.05%           
=======================================
  Files          38       38           
  Lines        2858     2858           
=======================================
  Hits         2288     2288           
  Misses        570      570           
Flag Coverage Δ
#unittests 80.05% <100.00%> (ø)
Impacted Files Coverage Δ
src/core/build.jl 100.00% <100.00%> (ø)
src/core/defcomp.jl 91.19% <0.00%> (ø)
src/core/connections.jl 87.03% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a24552...6098dd1. Read the comment docs.

@davidanthoff davidanthoff marked this pull request as ready for review June 5, 2020 18:04
@corakingdon corakingdon merged commit 1d356de into master Jun 5, 2020
@corakingdon corakingdon deleted the build-defaults branch June 5, 2020 19:01
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.

2 participants