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

Check units of coordinates #683

Merged
merged 40 commits into from
Feb 11, 2022
Merged

Conversation

vhirtham
Copy link
Collaborator

@vhirtham vhirtham commented Jan 24, 2022

Changes

Adds unit support for the LCS and CSM coordinates without requiring units.

Related Issues

#682 (do not close)

Checks

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

@vhirtham vhirtham added transformations everything related to the LCS / CSM units unit handling and pint labels Jan 24, 2022
@github-actions
Copy link

github-actions bot commented Jan 24, 2022

Unit Test Results

       1 files  ±  0         1 suites  ±0   2m 13s ⏱️ +23s
2 152 tests +44  2 152 ✔️ +44  0 💤 ±0  0 ±0 

Results for commit 0bbc0a8. ± Comparison against base commit 15ad366.

♻️ This comment has been updated with latest results.

Comment on lines +303 to +305
# The first branch is a workaround until units are mandatory
if coordinates.data.u == pint.Unit(""):
coordinates.data = coordinates.data.m
Copy link
Member

Choose a reason for hiding this comment

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

This looks dangerous to me, I guess the assumption is that if a 'dimensionless' quantity is passed we interpret it as 'default unit' ?
I would prefer to be strict here and force all quantities to be [length] so that at least the quantity behavior is already consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem is that our "unitless" code breaks at multiple places when we remove this line. This is just a workaround to enable units as input without enforcing them. For example, the "TimeSeries" returns unitless quantities in several tests and examples/notebooks. Fixing those problems is part of the transitions second step.

Copy link
Member

Choose a reason for hiding this comment

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

ah I see, thank you
Is it only tests/notebooks or also inside the package?

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #683 (0bbc0a8) into master (15ad366) will decrease coverage by 0.00%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #683      +/-   ##
==========================================
- Coverage   96.06%   96.05%   -0.01%     
==========================================
  Files          92       92              
  Lines        6350     6392      +42     
==========================================
+ Hits         6100     6140      +40     
- Misses        250      252       +2     
Impacted Files Coverage Δ
weldx/transformations/cs_manager.py 98.79% <ø> (-0.01%) ⬇️
weldx/visualization/k3d_impl.py 80.00% <90.47%> (+0.87%) ⬆️
weldx/constants.py 100.00% <100.00%> (ø)
weldx/geometry.py 98.51% <100.00%> (-0.11%) ⬇️
weldx/transformations/local_cs.py 97.13% <100.00%> (+0.08%) ⬆️
weldx/transformations/types.py 100.00% <100.00%> (ø)
weldx/visualization/matplotlib_impl.py 91.25% <100.00%> (+0.46%) ⬆️

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 15ad366...0bbc0a8. Read the comment docs.

@vhirtham vhirtham marked this pull request as ready for review February 1, 2022 07:54
@vhirtham
Copy link
Collaborator Author

vhirtham commented Feb 1, 2022

This is ready now. Remember that it is just an intermediate step with the goal to add unit support to LCS and CSM without breaking code that does not provide units. So there are some workarounds involved that will disappear later.

What doesn't work anymore are mixed cases. So if some of the LCS in a CSM have units while some others don't, you will get an error. This was the case in some of the notebooks so I had to adjust them.

@vhirtham vhirtham requested a review from marscher February 1, 2022 10:12
Copy link
Member

@CagtayFabry CagtayFabry left a comment

Choose a reason for hiding this comment

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

There seem to be quite a few UnitStrippedWarning in some of the tutorials now, e.g. https://weldx--683.org.readthedocs.build/en/683/tutorials/welding_example_02_weaving.html#add-a-sine-wave-to-the-TCP-movement

I guess it is the same line causing each

@vhirtham
Copy link
Collaborator Author

Couldn't stick to the original plan (not touching k3d) due to the unit stripped warnings now being errors. However, got everything working now. Additionally, I moved the default units to weldx.constants.

@vhirtham vhirtham merged commit 227a41d into BAMWelDX:master Feb 11, 2022
" groove_angle=Q_(50, \"deg\"),\n",
" root_face=Q_(1, \"mm\"),\n",
" root_gap=Q_(1, \"mm\"),\n",
" workpiece_thickness=\"0.5 cm\",\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it also have been possible to pass a tuple[Union[float, int], str], e.g. (1, "mm")? I would prefer such an option, if these quantities are actually the result of a computation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure at this specific point since I didn't touch the internals of the function. Just fixed an issue that popped up due to the function using the LCS. Anyways, all newer functions that support units should usually provide several format options for quantities. I think a tuple is also possible, but I have to check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations everything related to the LCS / CSM units unit handling and pint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants