Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes are meant to address the concerns raised in issue #456. To summarize that issue, when manually adding model members of a model's member dictionary it was previously possible to run into scenarios where the values returned for certain public facing attributes, such as the list of parameter labels, had fallen out of sync with the current constituents of the model. In this PR this has been addressed by adding additional checks to various public facing model attributes which check whether we need to rebuild the model, and performs that rebuild if needed before returning the requested value.
This specifically adds checks to the
parameters_labels
,set_parameter_label
,parameter_bounds
andnum_modeltest_params
properties/methods.Also included is an unrelated bug in the
Circuit
class which got caught by unit testing.In the course of testing these changes I also discovered some unexpected and undocumented behavior related to the handling of parameter bounds during the model rebuild stage. When manually setting parameter bounds at the
Model
level and not at theModelMember
level these manually specified values get overwritten during the rebuild process by whatever values (if any) are present in the constituent model members. We now have a check in the rebuild process which detects when there is a non-trivial parameter bound vector for a model, and a warning is raised alerting users to this behavior and the possible need to reset any manually specified parameter bounds again at the Model level (if appropriate).