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

Overhaul implementation of AutoSlots.__deepcopy__ #3413

Merged
merged 13 commits into from
Nov 14, 2024

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

This resolves some lingering issues when deepcopying AutoSlot classes / Pyomo models.

  • Ensure that the temporary state created when deepcopying Components is preserved until deepcopy is finished. This is a more robust solution to a patch that was introduced in Fix bug in AutoSlots deepcopy #3412
  • Remove redundant deepcopy implementations (standardize all logic in AutoSlots)
  • Fix a minor logic error when determining if components are in/out of the __block_scope__
  • Minor performance improvements (enough so that pmedian8 runs slightly faster, even after the additional overhead of keeping the temporary states alive)

Changes proposed in this PR:

  • (see above)

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:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

pyomo/common/autoslots.py Outdated Show resolved Hide resolved
pyomo/common/autoslots.py Show resolved Hide resolved
@blnicho blnicho self-requested a review November 13, 2024 20:54
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.66%. Comparing base (fe3f83f) to head (57e6082).
Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3413      +/-   ##
==========================================
+ Coverage   84.77%   88.66%   +3.89%     
==========================================
  Files         879      879              
  Lines      100380   100383       +3     
==========================================
+ Hits        85097    89006    +3909     
+ Misses      15283    11377    -3906     
Flag Coverage Δ
linux 86.12% <100.00%> (?)
osx 76.11% <100.00%> (?)
other 86.61% <100.00%> (?)
win 84.50% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blnicho blnicho merged commit 05c5ff2 into Pyomo:main Nov 14, 2024
36 checks passed
@jsiirola jsiirola deleted the autoslots-deepcopy branch November 15, 2024 03:21
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