-
Notifications
You must be signed in to change notification settings - Fork 55
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
Method parameter_labels()
returns an empty array
#456
Comments
Hi @Pablovinas, thanks for the detailed report! This isn't a bug per se, but rather related to a fairly old design choice to make the parameter management for models update lazily. As you've identified above, as currently implemented simply assigning a new value to a model member in one of the There are a couple options I can think of on how to proceed, so I wanted to open up some discussion on this to see what other folks think.
I suspect the answer is 3, but am open to thoughts on this. Option 2 would address the particular problem that you encountered above, but it would leave the door open to other possible avenues for desynchronization. As an example, models typically inherit their parameter labels from the parameter labels of the constituent model member objects (though not always strictly so, as in the case of parameter collection which you mentioned using above). With just the fix in option 2 it would be possible to create a desynchronization condition by querying the model's parameter labels immediately after manually updating the parameter labels for one of it's children. Option 1 would address this, but has the potential for non-trivial performance impacts if we aren't careful, so I'd want to check to make sure we aren't calling the |
Closed with #482 |
Describe the bug
After adding operations to an explicit model constructed via
pygsti.models.ExplicitOpModel()
, the methodparameter_labels()
returns an empty array and does not recognize the model's parameters. If the model has been initially imported frompygsti.modelpacks
, the array is not updated with the new parameters.To Reproduce
Steps to reproduce the behavior:
ExplicitModel.ipynb
tutorial. We can additionally define custom operations as in theCustomOperator.ipynb
tutorial and keep track of our parameters after naming them using theparameter_labels(self)
property.mdl.parameter_labels
to get the vector of model member's parameters within the model. It returns an empty array, causing further issues such as thecollect_parameters()
method not working.Expected behavior
I would expect the labels and parameters defined in the operations to be automatically recognised and updated in the model containing them.
Environment:
Additional context
I have been able to circumvent this issue by explicitly using
mdl._rebuild_paramvec()
. However, I believe this should be done automatically when defining the model.The text was updated successfully, but these errors were encountered: