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

set pint default unit format to short notation #519

Merged
merged 12 commits into from
Sep 15, 2021

Conversation

CagtayFabry
Copy link
Member

@CagtayFabry CagtayFabry commented Sep 14, 2021

Changes

use pint short notation for units as default

I encountered some problems with serialization using short notation (not sure why), so explicitly keeping the long notation there
Since tests are running fine now I have explicitly set the format for pint.Unit serialization to short notation, I think this is the most concise (and readable) notation in the file.
The user can still change the default formatting of the WELDX_UNIT_REGISTRY but it will not affect the serialization output

Checks

  • updated CHANGELOG.md
  • updated tests

@CagtayFabry CagtayFabry added the units unit handling and pint label Sep 14, 2021
@@ -454,7 +455,7 @@ def test_get_signal_data(self):
mc.add_transformation(self._default_transformation(), data=data)
mc.create_transformation("transformation_2", None, output_signal_unit="A")

assert mc.get_signal_data("transformation").identical(data)
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not really sure why this worked in the first place since get_signal_data is supposed to return a TimeSeries (which doesn't have .identical) 🤔

Copy link
Collaborator

@vhirtham vhirtham Sep 15, 2021

Choose a reason for hiding this comment

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

Is that what the type hint says or the actual code? Maybe the type hints or the code need an adjustment too.

Copy link
Member Author

Choose a reason for hiding this comment

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

the type hint says TimeSeries but I didn't check any further (the code looks more like xarray)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm... strange. Will have to check this on my own. Usually, this should be caught by mypy

@codecov
Copy link

codecov bot commented Sep 14, 2021

Codecov Report

Merging #519 (8fc303b) into master (efa6b23) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 8fc303b differs from pull request most recent head df34884. Consider uploading reports for the commit df34884 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #519      +/-   ##
==========================================
- Coverage   95.15%   95.13%   -0.02%     
==========================================
  Files          93       93              
  Lines        5638     5637       -1     
==========================================
- Hits         5365     5363       -2     
- Misses        273      274       +1     
Impacted Files Coverage Δ
weldx/constants.py 100.00% <100.00%> (ø)
weldx/measurement.py 95.51% <100.00%> (-0.04%) ⬇️
weldx/tags/unit/pint_quantity.py 100.00% <100.00%> (ø)
weldx/transformations/rotation.py 97.29% <0.00%> (-2.71%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efa6b23...df34884. Read the comment docs.

@CagtayFabry CagtayFabry marked this pull request as ready for review September 14, 2021 14:01
@CagtayFabry
Copy link
Member Author

updated to use short notation for serialization, see above

@CagtayFabry CagtayFabry merged commit 2e9648a into BAMWelDX:master Sep 15, 2021
@CagtayFabry CagtayFabry deleted the default_pint_format branch September 15, 2021 13:28
@CagtayFabry CagtayFabry mentioned this pull request Sep 27, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
units unit handling and pint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants