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

fix pint 0.21 related errors #876

Merged
merged 5 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## 0.6.7 (unreleased)

### Fixes

- fix compatibility with `pint=0.21` \[{pull}`876`\] .

## 0.6.6 (19.04.2023)

Version `0.6.6` is a compatibility release for `xarray>=2023.4.0` .
Expand Down
4 changes: 2 additions & 2 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ def _update_internals_and_get_series(self) -> SpatialSeries:
self._radius = Q_(np.linalg.norm(diff.m), self._points.u)

expr = "(x*cos(a+s*w)+y*sin(a+s*w))*r + o"
sign = -1 if np.cross([1, 0], diff) < 0 else 1
a = np.arccos(np.dot([1, 0], diff) / self._radius) * sign
sign = -1 if np.cross([1, 0], diff.m) < 0 else 1
a = np.arccos(np.dot([1, 0], diff.m) / self._radius.m) * sign

params = dict(
x=Q_([1, 0, 0], ""),
Expand Down
8 changes: 7 additions & 1 deletion weldx/tests/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pint
from pkg_resources import get_distribution

from weldx.constants import Q_
from weldx.geometry import _vector_is_close as vector_is_close
Expand Down Expand Up @@ -127,4 +128,9 @@ def matrix_is_close(mat_a, mat_b, abs_tol=1e-9) -> bool:

if mat_a.shape != mat_b.shape:
return False
return np.all(np.isclose(mat_a, mat_b, atol=abs_tol)).__bool__()

atol_unit = 1.0
if isinstance(mat_b, pint.Quantity) and get_distribution("pint").version >= "0.21":
atol_unit = mat_b.u

return np.all(np.isclose(mat_a, mat_b, atol=abs_tol * atol_unit)).__bool__()
9 changes: 8 additions & 1 deletion weldx/tests/transformations/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Union

import numpy as np
from pkg_resources import get_distribution
from xarray import DataArray

import weldx.transformations as tf
Expand Down Expand Up @@ -77,7 +78,13 @@ def check_coordinate_system(
lcs.orientation, orientation_expected, positive_orientation_expected
)

assert np.allclose(lcs.coordinates.data, coordinates_expected, atol=1e-9)
atol_unit = 1.0
if get_distribution("pint").version >= "0.21":
atol_unit = coordinates_expected.u

assert np.allclose(
lcs.coordinates.data, coordinates_expected, atol=1e-9 * atol_unit
)


def check_cs_close(lcs_0, lcs_1):
Expand Down