Type check all exception arguments in component __call__ implementations#3538
Merged
jsiirola merged 27 commits intoPyomo:mainfrom Apr 1, 2025
Merged
Type check all exception arguments in component __call__ implementations#3538jsiirola merged 27 commits intoPyomo:mainfrom
exception arguments in component __call__ implementations#3538jsiirola merged 27 commits intoPyomo:mainfrom
Conversation
blnicho
approved these changes
Mar 25, 2025
Member
|
This is great, but should be promulgated to other expression objects: |
…o numvalue, removing the implementation of __call__ for IndexedParam
… the moment, adding to expr/base.py
…__ implementation
bool exception argumentexception arguments in component __call__ implementations
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3538 +/- ##
=======================================
Coverage 88.70% 88.71%
=======================================
Files 888 888
Lines 101963 102017 +54
=======================================
+ Hits 90445 90502 +57
+ Misses 11518 11515 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@jsiirola this is ready for another review. |
jsiirola
approved these changes
Mar 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #2922
Summary/Motivation:
Params and most other numeric- and Boolean-valued components are callable (to get the value), but they did not previously check that the
exceptionargument was in fact abool. This meant it was easy to make a typo missing a*character and silently rendering part of the expression constant (with the value of a Param, for example). This adds checks in the implementations of__call__thatexceptionis abool. I still think we should discuss deprecating call to evaluate entirely, but this is a much less invasive change that will raise an error for many typos that would otherwise create silently wrong models.Changes proposed in this PR:
exceptionargument in implementations of__call__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: