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

Warn for explicit declaration of immutable params with units #3004

Merged
merged 4 commits into from
Sep 25, 2023

Conversation

jsiirola
Copy link
Member

Fixes #3002

Summary/Motivation:

#3002 pointed out that we silently force Params with units to be mutable, even when the user explicitly sets mutable=False. This PR adds a warning when we convert a Param that was explicitly immutable to being a mutable Param.

Changes proposed in this PR:

  • Issue warning when Param is constructed with units and explicitly set to immutable.
  • Test this behavior

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.

@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (bdbcb31) 88.10% compared to head (8967037) 88.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3004      +/-   ##
==========================================
- Coverage   88.10%   88.08%   -0.02%     
==========================================
  Files         769      769              
  Lines       89520    89526       +6     
==========================================
- Hits        78869    78863       -6     
- Misses      10651    10663      +12     
Flag Coverage Δ
linux 85.18% <100.00%> (-0.01%) ⬇️
osx 74.99% <100.00%> (+<0.01%) ⬆️
other 85.36% <100.00%> (+<0.01%) ⬆️
win 82.43% <100.00%> (-0.02%) ⬇️

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

Files Coverage Δ
pyomo/core/base/param.py 82.07% <100.00%> (+0.28%) ⬆️

... and 2 files with indirect coverage changes

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

@blnicho blnicho merged commit a607763 into Pyomo:main Sep 25, 2023
30 checks passed
@jsiirola jsiirola deleted the param-units-mutable-warning branch November 27, 2023 21:08
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.

Inconsistent Param mutability with units
2 participants