Default scaler objects for properties and reactions#1766
Default scaler objects for properties and reactions#1766dallan-keylogic merged 13 commits intoIDAES:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1766 +/- ##
==========================================
- Coverage 73.83% 73.81% -0.02%
==========================================
Files 419 419
Lines 66225 66274 +49
Branches 11122 11133 +11
==========================================
+ Hits 48894 48919 +25
- Misses 14794 14814 +20
- Partials 2537 2541 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| # Python catches the error and raises its own AttributeError | ||
| # with its own message. Leave the error, though, in case | ||
| # the user looks through the code and ends up here. | ||
| raise AttributeError( | ||
| "{} has not assigned a StateBlock class to be associated " | ||
| "with this property package. Please contact the developer of " |
There was a problem hiding this comment.
Does that mean we know that this will never happen? In that case we should preempt the default error with our own, or remove the error since it is never happening anyways. Same with other ones in this PR, and I think that will help you on code coverage as well.
There was a problem hiding this comment.
No. What happens is that, if this error is triggered, either Python or the create-on-demand property framework will intercept this error in a try block, then raise its own AttributeError. I thought about removing the error message, but thought it still might be useful for users tracking down why they're getting an error.
| self.recursive_cons2 = Constraint(expr=self.recursion1 == 1) | ||
|
|
||
| def _raise_exception(self): | ||
| # PYLINT-TODO |
There was a problem hiding this comment.
What needs to be done here?
There was a problem hiding this comment.
I'm not sure---I copied that class from the tests for ReactionBase, which also has that TODO. I think I can strip out a significant amount of those methods for the test.
Fixes
Summary/Motivation:
When using the old scaling tools, we could set default scaling factors to use for all state blocks using a property package. With the new scaling tools, heretofore we have been forced to use changing the class attribute
DEFAULT_SCALING_FACTORS. Global mutation is dangerous and ought be avoided when possible.In this PR, I allow the user to specify a default scaler object to use for all instances of a property or reaction package in a flowsheet by setting the
default_state_scaler_objectordefault_reaction_scaler_objecton their respective parameter blocks.Additionally, I fixed the issue with the default scaler object for scaler state and reaction blocks.
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: