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

Units #10

Merged
merged 33 commits into from
Jul 23, 2024
Merged

Units #10

merged 33 commits into from
Jul 23, 2024

Conversation

siligam
Copy link
Contributor

@siligam siligam commented Jul 1, 2024

addressing issue #6

Just implemented the bare logic to handle unit conversion. No API design yet.
Features:

Normalisation of non-standard notation of units in netcdf4 so pint can read them.
added unit definitions which are not available in pint library.

@mandresm mandresm self-requested a review July 3, 2024 06:00
@mandresm
Copy link
Contributor

mandresm commented Jul 3, 2024

Closes #6

Copy link
Contributor

@mandresm mandresm left a comment

Choose a reason for hiding this comment

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

Hi @siligam, great PR! Just a few suggestions :)

src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
tests/test_units.py Outdated Show resolved Hide resolved
Copy link
Member

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

I think this is a good start but it still needs some work, in particular some of the key logic for integration into the rest of the toolchain is not yet there.

tests/test_units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units_en.txt Outdated Show resolved Hide resolved
tests/test_units.py Show resolved Hide resolved
@pgierz pgierz linked an issue Jul 16, 2024 that may be closed by this pull request
@pgierz pgierz self-requested a review July 17, 2024 06:22
Copy link
Member

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

It's getting there, keep up the good work :-)

I still have a design point, one major, and a few minor comments. The major missing part still has not yet been addressed, namely a function to hook into the pipeline. See the in-line comments for some minor revision recommendations in addition to the checklist below.

Design

  • I am not sure about the chemistry units still. The unit is mol or gram. mmol is still mole, prefixed by milli, and pint should be able to handle prefixes. A mole of carbon is still a mole, it just happens to be of the element carbon, (just like a kilogram of flour is a kilogram, or sugar, or butter, or whatever you want to use to bake cookies with)

Major Suggestion

  • Missing a key function to tie together all the logic

General Minor Suggestions

  • f-strings everywhere for consistency
  • Make sure all print statements are logger statements. It's up to you to think about what level they can have.

src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units_en.txt Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
tests/test_units.py Show resolved Hide resolved
Copy link
Member

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

Excellent work @siligam! I only have one more small thing that you should look at, just to be sure: The metadata attribute name on units should be plural (it already is), but I am not 100% sure so I'd like to double check.

You can also add a call to handle_unit_conversion to the generic pipeline. We can have a brief meeting so I can show you where to do that! Once that is in place, we can merge this into the main branch 🙂

src/pymorize/units.py Outdated Show resolved Hide resolved
src/pymorize/units.py Show resolved Hide resolved
src/pymorize/units.py Show resolved Hide resolved
tests/test_units.py Outdated Show resolved Hide resolved
tests/test_units.py Show resolved Hide resolved
src/pymorize/units.py Outdated Show resolved Hide resolved
@siligam
Copy link
Contributor Author

siligam commented Jul 23, 2024

Excellent work @siligam! I only have one more small thing that you should look at, just to be sure: The metadata attribute name on units should be plural (it already is), but I am not 100% sure so I'd like to double check.

I checked that units are indeed plural and I am sure I did use plural when setting the attribute.

You can also add a call to handle_unit_conversion to the generic pipeline. We can have a brief meeting so I can show you where to do that! Once that is in place, we can merge this into the main branch 🙂

Sure we can discuss this in a brief meeting.

@pgierz pgierz self-requested a review July 23, 2024 10:06
Copy link
Member

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

Looks good, we can merge this!

@siligam siligam requested a review from mandresm July 23, 2024 10:09
@pgierz pgierz merged commit 4460934 into main Jul 23, 2024
4 checks passed
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.

Unit Conversions
3 participants