-
Notifications
You must be signed in to change notification settings - Fork 562
Rework handling of 'dimensionless' units in Pyomo #2691
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
Conversation
Codecov ReportBase: 87.13% // Head: 87.13% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2691 +/- ##
=======================================
Coverage 87.13% 87.13%
=======================================
Files 757 757
Lines 84664 84674 +10
=======================================
+ Hits 73770 73780 +10
Misses 10894 10894
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
mrmundt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this code well enough to have a good idea of whether this is an efficient/good solution, but for what I do know, it looks fine to me (minus the smallest of typos).
Fixes #1570.
Summary/Motivation:
@andrewlee94 reported strangeness with units where the following did not raise an error:
This was due to
get_units()returningNoneinstead ofdimensionless. This caused Pyomo to not be able to distinguish betweenVar(), andVar(units=units.dimensionless). This PR changes the current behavior so thatget_units()will always return a_PyomoUnit.In addition, this PR reworks the
PintUnitExtractionVisitorto make it slightly more performant.While much of #1570 has already been fixed on
main, this PR fixes the last known issues.Changes proposed in this PR:
dimentionlessis returned fromget_units()instead ofNonePintUnitExtractionVisitorLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: