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

custom wx_unit validation behavior #739

Merged
merged 6 commits into from
Apr 21, 2022

Conversation

CagtayFabry
Copy link
Member

@CagtayFabry CagtayFabry commented Apr 19, 2022

Changes

  • add support for custom unit validation via units_from_tagged and _get_instance_units
  • numeric base types (int, float, ndarray) validate against dimensionless
  • data_array now directly supports validation with wx_unit
  • pd.Timedelta, pd.TimedeltaIndex and timedelta-like weldx.Time will validate against wx_unit: "s"

Related Issues

Closes #95

Checks

  • updated CHANGELOG.rst
  • updated tests
  • updated doc/
  • update example/tutorial notebooks
  • update manifest file

@CagtayFabry CagtayFabry added ASDF everything ASDF related (python + schemas) validation custom ASDF validators labels Apr 19, 2022
@CagtayFabry
Copy link
Member Author

We still have to think about the behavior when not unit information can be found or the property is missing as discussed in #184

@github-actions
Copy link

github-actions bot commented Apr 19, 2022

Unit Test Results

       1 files  ±0         1 suites  ±0   3m 1s ⏱️ -1s
2 163 tests +5  2 163 ✔️ +5  0 💤 ±0  0 ±0 

Results for commit 06a95bb. ± Comparison against base commit 96d9bbc.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Apr 19, 2022

Codecov Report

Merging #739 (06a95bb) into master (96d9bbc) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
+ Coverage   95.88%   95.89%   +0.01%     
==========================================
  Files          92       92              
  Lines        6489     6511      +22     
==========================================
+ Hits         6222     6244      +22     
  Misses        267      267              
Impacted Files Coverage Δ
weldx/asdf/util.py 90.64% <100.00%> (+0.44%) ⬆️
weldx/asdf/validators.py 98.13% <100.00%> (+0.01%) ⬆️
weldx/tags/core/data_array.py 100.00% <100.00%> (ø)
weldx/tags/debug/test_unit_validator.py 100.00% <100.00%> (ø)

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 96d9bbc...06a95bb. Read the comment docs.

@CagtayFabry CagtayFabry added this to the 0.6.0 milestone Apr 20, 2022
@CagtayFabry CagtayFabry requested a review from vhirtham April 20, 2022 17:54
@CagtayFabry CagtayFabry marked this pull request as ready for review April 20, 2022 17:54
@CagtayFabry
Copy link
Member Author

This should be ready to go now, feel free to merge if you agree @vhirtham 🚀

@marscher
Copy link
Contributor

marscher commented Apr 21, 2022

Thanks for this improvement. Would it be possible to also accept "" instead of"<space>"as an empty unit definition?

@vhirtham vhirtham merged commit f64658d into BAMWelDX:master Apr 21, 2022
@CagtayFabry CagtayFabry deleted the from_instance_units branch April 21, 2022 09:03
@CagtayFabry
Copy link
Member Author

CagtayFabry commented Apr 21, 2022

Thanks for this improvement. Would it be possible to also accept "" instead of"<space>"as an empty unit definition?

I'm not sure what happens with "" actually, maybe it works? (I guess it depends on what YAML parses from "" and what pint unit gets build from that)
Something like "dimensionless" should also work

maybe you can give it a try by making changes here and running the tests

dimensionless:
description: a basic numeric type without any units or dimensionless quantity
wx_unit: " "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASDF everything ASDF related (python + schemas) validation custom ASDF validators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom wx_unit validation behavior
3 participants