Skip to content

Commit

Permalink
Expediate removal of 'convention' in some Quaternion methods to 0.13
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <[email protected]>
  • Loading branch information
hakonanes committed Apr 22, 2023
1 parent e0e051f commit 6d9a527
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Added

Changed
-------
- The ``convention`` parameter in ``from_euler()`` and ``to_euler()`` will be removed in
the next minor release, 0.13, instead of release 1.0 as previously stated.

Deprecated
----------
Expand Down
8 changes: 4 additions & 4 deletions orix/quaternion/quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ def from_axes_angles(
q = cls.from_neo_euler(axangle).unit
return q

# TODO: Remove decorator, **kwargs, and use of "convention" in 1.0
# TODO: Remove decorator, **kwargs, and use of "convention" in 0.13
@classmethod
@deprecated_argument("convention", "0.9", "1.0", "direction")
@deprecated_argument("convention", "0.9", "0.13", "direction")
def from_euler(
cls,
euler: Union[np.ndarray, tuple, list],
Expand Down Expand Up @@ -772,8 +772,8 @@ def outer(
"with `other` of type `Quaternion` or `Vector3d`"
)

# TODO: Remove decorator and **kwargs in 1.0
@deprecated_argument("convention", since="0.9", removal="1.0")
# TODO: Remove decorator and **kwargs in 0.13
@deprecated_argument("convention", since="0.9", removal="0.13")
def to_euler(self, degrees: bool = False, **kwargs) -> np.ndarray:
r"""Return the normalized quaternions as Euler angles in the
Bunge convention :cite:`rowenhorst2015consistent`.
Expand Down
4 changes: 2 additions & 2 deletions orix/quaternion/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def from_axes_angles(
"""
return super().from_axes_angles(axes, angles, degrees)

# TODO: Remove **kwargs in 1.0.
# TODO: Remove **kwargs in 0.13
# Deprication decorator is implemented in Quaternion
@classmethod
def from_euler(
Expand Down Expand Up @@ -719,7 +719,7 @@ def to_matrix(self) -> np.ndarray:
"""
return super().to_matrix()

# TODO: Remove **kwargs in 1.0
# TODO: Remove **kwargs in 0.13
def to_euler(self, degrees: bool = False, **kwargs) -> np.ndarray:
r"""Return the rotations as Euler angles in the Bunge convention
:cite:`rowenhorst2015consistent`.
Expand Down
10 changes: 5 additions & 5 deletions orix/tests/quaternion/test_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_from_scipy_rotation(self):
with pytest.raises(TypeError, match="Value must be an instance of"):
_ = Orientation.from_scipy_rotation(r_scipy, (Oh, Oh))

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_from_euler_warns(self):
"""Orientation.from_euler() warns only once when "convention"
argument is passed.
Expand All @@ -573,7 +573,7 @@ def test_from_euler_warns(self):
_ = Orientation.from_euler(euler)

msg = (
r"Argument `convention` is deprecated and will be removed in version 1.0. "
r"Argument `convention` is deprecated and will be removed in version 0.13. "
r"To avoid this warning, please do not use `convention`. "
r"Use `direction` instead. See the documentation of `from_euler\(\)` for "
"more details."
Expand All @@ -582,7 +582,7 @@ def test_from_euler_warns(self):
_ = Orientation.from_euler(euler, convention="whatever")
assert len(record2) == 1

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_from_euler_convention_mtex(self):
"""Passing convention="mtex" to Orientation.from_euler() works
but warns once.
Expand All @@ -593,7 +593,7 @@ def test_from_euler_convention_mtex(self):
ori2 = Orientation.from_euler(euler, convention="mtex")
assert np.allclose(ori1.data, ori2.data)

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_to_euler_convention_warns(self):
"""Orientation.to_euler() warns only once when "convention"
argument is passed.
Expand All @@ -605,7 +605,7 @@ def test_to_euler_convention_warns(self):
ori2 = ori1.to_euler()

msg = (
r"Argument `convention` is deprecated and will be removed in version 1.0. "
r"Argument `convention` is deprecated and will be removed in version 0.13. "
r"To avoid this warning, please do not use `convention`. "
r"See the documentation of `to_euler\(\)` for more details."
)
Expand Down
10 changes: 5 additions & 5 deletions orix/tests/quaternion/test_quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_passing_degrees_warns(self):
q = Quaternion.from_euler([90, 0, 0])
assert np.allclose(q.data, [0.5253, 0, 0, -0.8509], atol=1e-4)

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_from_euler_warns(self, eu):
"""Quaternion.from_euler() warns only when "convention" argument
is passed.
Expand All @@ -366,15 +366,15 @@ def test_from_euler_warns(self, eu):
_ = Quaternion.from_euler(eu)

msg = (
r"Argument `convention` is deprecated and will be removed in version 1.0. "
r"Argument `convention` is deprecated and will be removed in version 0.13. "
r"To avoid this warning, please do not use `convention`. "
r"Use `direction` instead. See the documentation of `from_euler\(\)` for "
"more details."
)
with pytest.warns(np.VisibleDeprecationWarning, match=msg):
_ = Quaternion.from_euler(eu, convention="whatever")

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_from_euler_convention_mtex(self, eu):
"""Passing convention="mtex" to Quaternion.from_euler() works but
warns.
Expand All @@ -384,7 +384,7 @@ def test_from_euler_convention_mtex(self, eu):
q2 = Quaternion.from_euler(eu, convention="mtex")
assert np.allclose(q1.data, q2.data)

# TODO: Remove in 1.0
# TODO: Remove in 0.13
def test_to_euler_convention_warns(self, eu):
"""Quaternion.to_euler() warns only when "convention" argument is
passed.
Expand All @@ -397,7 +397,7 @@ def test_to_euler_convention_warns(self, eu):
q2 = q1.to_euler()

msg = (
r"Argument `convention` is deprecated and will be removed in version 1.0. "
r"Argument `convention` is deprecated and will be removed in version 0.13. "
r"To avoid this warning, please do not use `convention`. "
r"See the documentation of `to_euler\(\)` for more details."
)
Expand Down

0 comments on commit 6d9a527

Please sign in to comment.