Skip to content

Commit

Permalink
remove deprecated normalized argument in from_quat signature (#224)
Browse files Browse the repository at this point in the history
* remove deprecated normalized argument in from_quat signature

* scipy<1.6

* merge some if statements

* update CHANGELOG.md

Co-authored-by: Hirthammer <volker.hirthammer@bam.de>
  • Loading branch information
CagtayFabry and vhirtham authored Jan 25, 2021
1 parent e1b5532 commit 60fb362
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- python=3.7
- numpy>=1.18
- pandas>=1.0
- scipy>=1.4
- scipy<1.6
- sympy>=1.6
- xarray>=0.15
- pint>=0.11
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
name: pytest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
py: ['3.7', '3.8']
Expand Down Expand Up @@ -42,10 +43,11 @@ jobs:
- name: pip installs
run: |
pip install pytest pytest-cov setuptools_scm
pip install .
pip install -e .
- name: run pytest
run: |
pytest --runslow
echo "Exited with '$?'"
coverage xml
- name: codecov.io
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Notes

## 0.2.3 (unreleased)
## 0.3.0 (unreleased)
### added
- add `weldx.transformations.CoordinateSystemManager.relabel` function [[#219]](https://github.com/BAMWelDX/weldx/pull/219)

Expand All @@ -24,9 +24,11 @@
- don't inline time dependent `LCS.coordinates` [[#222]](https://github.com/BAMWelDX/weldx/pull/222)
- fix "datetime64" passing for "timedelta64" in `xr_check_coords` [[#221]](https://github.com/BAMWelDX/weldx/pull/221)
- fix `time_ref_restore` not working correctly if no `time_ref` was set [[#221]](https://github.com/BAMWelDX/weldx/pull/221)
- fix deprecated signature in `WXRotation` [[#224]](https://github.com/BAMWelDX/weldx/pull/224)

### dependencies
- Add [PyFilesystem](https://docs.pyfilesystem.org/en/latest/)(`fs`) as new dependency
- Add [PyFilesystem](https://docs.pyfilesystem.org/en/latest/)(`fs`) as new dependency
- restrict `scipy<1.6` pending [ASDF #916](https://github.com/asdf-format/asdf/issues/916) [[#224]](https://github.com/BAMWelDX/weldx/pull/224)


## 0.2.2 (30.11.2020)
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- setuptools_scm
- numpy>=1.18
- pandas>=1.0
- scipy=1.5.3
- scipy<1.6
- sympy>=1.6
- xarray>=0.15
- pint>=0.11
Expand Down
2 changes: 1 addition & 1 deletion weldx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

try:
from ._version import __version__
except ModuleNotFoundError:
except ModuleNotFoundError: # pragma: no cover
__version__ = None
warnings.warn(
"Using local weldx package files without version information.\n"
Expand Down
38 changes: 22 additions & 16 deletions weldx/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ class WXRotation(Rot):
"""Wrapper for creating meta-tagged Scipy.Rotation objects."""

@classmethod
def from_quat(cls, quat: np.ndarray, normalized=None) -> "WXRotation":
def from_quat(cls, quat: np.ndarray) -> "WXRotation":
"""Initialize from quaternions.
scipy.spatial.transform.Rotation docs for details.
"""
rot = super().from_quat(quat, normalized)
rot.wx_meta = {"constructor": "from_quat"}
rot = super().from_quat(quat)
setattr(rot, "wx_meta", {"constructor": "from_quat"})
return rot

@classmethod
Expand All @@ -368,7 +368,7 @@ def from_matrix(cls, matrix: np.ndarray) -> "WXRotation":
scipy.spatial.transform.Rotation docs for details.
"""
rot = super().from_matrix(matrix)
rot.wx_meta = {"constructor": "from_matrix"}
setattr(rot, "wx_meta", {"constructor": "from_matrix"})
return rot

@classmethod
Expand All @@ -377,8 +377,8 @@ def from_rotvec(cls, rotvec: np.ndarray) -> "WXRotation":
scipy.spatial.transform.Rotation docs for details.
"""
rot = Rot.from_rotvec(rotvec)
rot.wx_meta = {"constructor": "from_rotvec"}
rot = super().from_rotvec(rotvec)
setattr(rot, "wx_meta", {"constructor": "from_rotvec"})
return rot

@classmethod
Expand All @@ -387,8 +387,12 @@ def from_euler(cls, seq: str, angles, degrees: bool = False) -> "WXRotation":
scipy.spatial.transform.Rotation docs for details.
"""
rot = Rot.from_euler(seq=seq, angles=angles, degrees=degrees)
rot.wx_meta = {"constructor": "from_euler", "seq": seq, "degrees": degrees}
rot = super().from_euler(seq=seq, angles=angles, degrees=degrees)
setattr(
rot,
"wx_meta",
{"constructor": "from_euler", "seq": seq, "degrees": degrees},
)
return rot


Expand Down Expand Up @@ -478,11 +482,14 @@ def __init__(
raise ValueError("Orientation vectors must be orthogonal")

# unify time axis
if ("time" in orientation.coords) and ("time" in coordinates.coords):
if not np.all(orientation.time.data == coordinates.time.data):
time_union = ut.get_time_union([orientation, coordinates])
orientation = ut.xr_interp_orientation_in_time(orientation, time_union)
coordinates = ut.xr_interp_coordinates_in_time(coordinates, time_union)
if (
("time" in orientation.coords)
and ("time" in coordinates.coords)
and (not np.all(orientation.time.data == coordinates.time.data))
):
time_union = ut.get_time_union([orientation, coordinates])
orientation = ut.xr_interp_orientation_in_time(orientation, time_union)
coordinates = ut.xr_interp_coordinates_in_time(coordinates, time_union)

coordinates.name = "coordinates"
orientation.name = "orientation"
Expand Down Expand Up @@ -1121,9 +1128,8 @@ def interp_time(
"allowed. Also check that the reference time has the correct type."
)

if self.has_reference_time:
if not isinstance(time, pd.DatetimeIndex):
time = time + time_ref
if self.has_reference_time and (not isinstance(time, pd.DatetimeIndex)):
time = time + time_ref

orientation = ut.xr_interp_orientation_in_time(self.orientation, time)
coordinates = ut.xr_interp_coordinates_in_time(self.coordinates, time)
Expand Down

0 comments on commit 60fb362

Please sign in to comment.