Adding private_data to _BlockData
#3138
Merged
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.
Fixes # .
Summary/Motivation:
We've maintained for awhile that we should not store state on transformation objects, and that we should instead do it on the model. That's all well and good except that we have never reserved a place for ourselves to do so. This adds a
_private_data_dict
attribute on_BlockData
that is initialized asNone
, but when asked for (and given a scope (that is either the caller's module name or a parent of the caller's module name)), becomes a dictionary with keys being the name of the scope (e.g.pyomo.gdp
orpyomo.gdp.bigm
) and values being dictionaries to be used however the transformation/solver/anything else desires. This should simplify building and maintaining APIs for transformations to map between original and transformed components and store other state that might be needed later, and is actually private because of the restriction on keys. Even if a user used this, they would have to use keys from their scope, not ours.Changes proposed in this PR:
_private_data
property andprivate_data
method to_BlockData
Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: