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

Adding UnitSet object to manage definition of base and derived units #991

Merged
merged 12 commits into from
Oct 19, 2022

Conversation

andrewlee94
Copy link
Member

Part of #669

Summary/Motivation:

As a start towards removing a number of "magic string constants" in the IDAES codebase, this PR introduces a new UnitSet object which defines the set of known quantities in IDAES as properties along with their define units of measurement. For backwards compatibility, UnitSets allow quantities to be accessed in a dict-like fashion using a string for the quantity name, but as this is rolled out we will begin replacing instances of this in the codebase with direct references to the properties on the UnitSet.

Changes proposed in this PR:

  • Add new UnitSet object, and replaces existent _default_units and _derived_units dicts with this in properties_meta.
  • Adds standalone tests for UnitSets.
  • Updates tests which relied on the old dict format to use UnitSets instead.

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  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.

@andrewlee94 andrewlee94 self-assigned this Oct 17, 2022
@andrewlee94 andrewlee94 added enhancement New feature or request Priority:Normal Normal Priority Issue or PR core Issues dealing with core modeling components labels Oct 17, 2022
@andrewlee94
Copy link
Member Author

I should also write some docs for the new UnitSet, but I think these don;t need to be too extensive as this is mostly an internal object that users won't see much.

Copy link
Contributor

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions (I think we can make this implementation simpler)...

idaes/core/base/property_meta.py Outdated Show resolved Hide resolved
idaes/core/base/property_meta.py Outdated Show resolved Hide resolved
idaes/core/base/reaction_base.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Base: 69.98% // Head: 70.04% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (098dac6) compared to base (5182626).
Patch coverage: 98.55% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #991      +/-   ##
==========================================
+ Coverage   69.98%   70.04%   +0.05%     
==========================================
  Files         400      400              
  Lines       66171    66275     +104     
  Branches    12204    12201       -3     
==========================================
+ Hits        46308    46420     +112     
+ Misses      17486    17484       -2     
+ Partials     2377     2371       -6     
Impacted Files Coverage Δ
idaes/core/base/property_meta.py 96.82% <98.52%> (+6.34%) ⬆️
idaes/core/base/reaction_base.py 82.19% <100.00%> (-0.10%) ⬇️
idaes/ver.py 61.53% <0.00%> (-4.62%) ⬇️
...roperties/general_helmholtz/helmholtz_functions.py 91.67% <0.00%> (+0.26%) ⬆️
idaes/core/dmf/util.py 55.55% <0.00%> (+1.19%) ⬆️
idaes/core/dmf/codesearch.py 100.00% <0.00%> (+1.44%) ⬆️
idaes/conftest.py 82.92% <0.00%> (+4.87%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@andrewlee94
Copy link
Member Author

@dangunter @jsiirola I think this is ready for the next round of reviews, and is hopefully almost ready to merge (I'll save updating the rest of the code base for a separate PR).

@andrewlee94 andrewlee94 enabled auto-merge (squash) October 19, 2022 17:22
@andrewlee94 andrewlee94 merged commit fcba12f into IDAES:main Oct 19, 2022
@andrewlee94 andrewlee94 deleted the issue_669_2 branch October 19, 2022 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues dealing with core modeling components enhancement New feature or request Priority:Normal Normal Priority Issue or PR
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants