An object's repr is intended to be either a valid Python construct to rebuild an equivalent object or something enclosed in angle brackets. Orientation.__repr__ matches neither of these.
Notably the test_repr which exists for the type fails to actually validate this, though it could with a small extension:
@given(tuples(floats(), floats(), floats()))
def test_repr(euler_angles: Tuple[float, float, float]) -> None:
"""Test that the representation is as expected."""
q = Quaternion(axis=euler_angles, scalar=1)
orientation = Orientation(*q.vector)
ypr = q.yaw_pitch_roll
names = ["rot_z", "rot_y", "rot_x"]
repr_str = repr(orientation)
for name, val in zip(names, ypr):
assert "{}={}".format(name, val) in repr_str
rebuilt = Orientation(**dict(zip(names, ypr)))
assert repr(rebuilt) == repr(orientation), "Repr value should round-trip"
diff --git a/tests/test_coords.py b/tests/test_coords.py
index d16f7f1..8790482 100644
--- a/tests/test_coords.py
+++ b/tests/test_coords.py
@@ -62,3 +62,7 @@ def test_repr(euler_angles: Tuple[float, float, float]) -> None:
for name, val in zip(names, ypr):
assert "{}={}".format(name, val) in repr_str
+
+ rebuilt = Orientation(**dict(zip(names, ypr)))
+
+ assert repr(rebuilt) == repr(orientation)
An object's
repris intended to be either a valid Python construct to rebuild an equivalent object or something enclosed in angle brackets.Orientation.__repr__matches neither of these.Notably the
test_reprwhich exists for the type fails to actually validate this, though it could with a small extension: