Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 27, 2025
1 parent fe7d1e5 commit 6880306
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 55 deletions.
54 changes: 27 additions & 27 deletions happypose_msgs/test/test_discretize_symmetries.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def test_only_discrete_np() -> None:
assert res.shape == (2, 4, 4), "Result shape is incorrect!"

for i, t in enumerate(res):
assert is_transform_in_se3_list(
t, [t1, t2]
), f"Discrete symmetry at index {i} did not match any of the initial ones!"
assert is_transform_in_se3_list(t, [t1, t2]), (
f"Discrete symmetry at index {i} did not match any of the initial ones!"
)


def test_only_discrete_ros() -> None:
Expand All @@ -159,18 +159,18 @@ def test_only_discrete_ros() -> None:

res = discretize_symmetries(msg, return_ros_msg=True)

assert len(res) == len(
msg.symmetries_discrete
), "Results list does not have all discrete symmetries from message received!"
assert len(res) == len(msg.symmetries_discrete), (
"Results list does not have all discrete symmetries from message received!"
)

assert all(
isinstance(r, Transform) for r in res
), "Returned type of elements in the list is not geometry_msgs.msg.Transform!"
assert all(isinstance(r, Transform) for r in res), (
"Returned type of elements in the list is not geometry_msgs.msg.Transform!"
)

for i, t in enumerate(res):
assert is_transform_msg_in_list(
t, msg.symmetries_discrete
), f"Discrete symmetry at index {i} did not match any initial ones in the message!"
assert is_transform_msg_in_list(t, msg.symmetries_discrete), (
f"Discrete symmetry at index {i} did not match any initial ones in the message!"
)


def test_only_continuous_np() -> None:
Expand Down Expand Up @@ -201,9 +201,9 @@ def test_only_continuous_np() -> None:
res = discretize_symmetries(msg, n_symmetries_continuous=n_symmetries)
assert res.shape == (n_symmetries, 4, 4), "Result shape is incorrect!"
for i, t in enumerate(res):
assert is_transform_in_se3_list(
t, t_list
), f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
assert is_transform_in_se3_list(t, t_list), (
f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
)


def test_only_continuous_ros() -> None:
Expand Down Expand Up @@ -235,16 +235,16 @@ def test_only_continuous_ros() -> None:
msg, n_symmetries_continuous=n_symmetries, return_ros_msg=True
)

assert len(res) == len(
t_list
), "Results list does not have all discrete symmetries from message received!"
assert len(res) == len(t_list), (
"Results list does not have all discrete symmetries from message received!"
)

t_msgs = [pin_to_msg(t) for t in t_list]

for i, t in enumerate(res):
assert is_transform_msg_in_list(
t, t_msgs
), f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
assert is_transform_msg_in_list(t, t_msgs), (
f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
)


def test_mixed_np() -> None:
Expand Down Expand Up @@ -299,9 +299,9 @@ def test_mixed_np() -> None:
print(res, flush=True)

for i, t in enumerate(res):
assert is_transform_in_se3_list(
t, t_test
), f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
assert is_transform_in_se3_list(t, t_test), (
f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
)


def test_mixed_ros() -> None:
Expand Down Expand Up @@ -354,6 +354,6 @@ def test_mixed_ros() -> None:
]

for i, t in enumerate(res):
assert is_transform_msg_in_list(
t, t_test
), f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
assert is_transform_msg_in_list(t, t_test), (
f"Discrete symmetry at index {i} did not match any symmetry from generated list!"
)
54 changes: 26 additions & 28 deletions happypose_ros/test/happypose_testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,12 @@ def get_params(
time.sleep(0.1)

assert future.done, (
"Timeout reached when spinning the service "
f"{self._get_param_cli.srv_name}!"
f"Timeout reached when spinning the service {self._get_param_cli.srv_name}!"
)

assert (
future.result() is not None
), f"Filed to call the service the service {self._set_param_cli.srv_name}!"
assert future.result() is not None, (
f"Filed to call the service the service {self._set_param_cli.srv_name}!"
)

return [
Parameter.from_parameter_msg(RCL_Parameter(name=name, value=param))
Expand Down Expand Up @@ -310,13 +309,12 @@ def set_params(self, parameters: List[Parameter], timeout: float = 5.0) -> None:
time.sleep(0.1)

assert future.done, (
"Timeout reached when spinning "
f"the service {self._set_param_cli.srv_name}!"
f"Timeout reached when spinning the service {self._set_param_cli.srv_name}!"
)

assert (
future.result() is not None
), f"Filed to call the service the service {self._set_param_cli.srv_name}!"
assert future.result() is not None, (
f"Filed to call the service the service {self._set_param_cli.srv_name}!"
)

if not future.result().result.successful:
"Failed to set parameters!"
Expand Down Expand Up @@ -570,9 +568,9 @@ def assert_pose_equal(
for p in (pose_1, pose_2)
]
diff = poses[0].inverse() * poses[1]
assert (
np.linalg.norm(pin.log6(diff).vector) < precision
), "Detected pose is not within specified precision!"
assert np.linalg.norm(pin.log6(diff).vector) < precision, (
"Detected pose is not within specified precision!"
)


def assert_transform_equal(
Expand Down Expand Up @@ -602,9 +600,9 @@ def assert_transform_equal(
for t in (transform_1, transform_2)
]
diff = poses[0].inverse() * poses[1]
assert (
np.linalg.norm(pin.log6(diff).vector) < precision
), "Given transformations are is not within specified precision!"
assert np.linalg.norm(pin.log6(diff).vector) < precision, (
"Given transformations are is not within specified precision!"
)


def assert_bbox(
Expand Down Expand Up @@ -633,21 +631,21 @@ def assert_bbox(
def _almost_equal(x: float, y: float, delta: float) -> bool:
return abs(x - y) < delta

assert _almost_equal(
msg.size_x, size_x, pixel_error_x
), "Bbox size in X is incorrect!"
assert _almost_equal(msg.size_x, size_x, pixel_error_x), (
"Bbox size in X is incorrect!"
)

assert _almost_equal(
msg.size_y, size_y, pixel_error_y
), "Bbox size in Y is incorrect!"
assert _almost_equal(msg.size_y, size_y, pixel_error_y), (
"Bbox size in Y is incorrect!"
)

assert _almost_equal(
msg.center.position.x, center_x, pixel_error_x
), "Bbox center in X is incrrect!"
assert _almost_equal(msg.center.position.x, center_x, pixel_error_x), (
"Bbox center in X is incrrect!"
)

assert _almost_equal(
msg.center.position.y, center_y, pixel_error_y
), "Bbox center in Y is incorrect!"
assert _almost_equal(msg.center.position.y, center_y, pixel_error_y), (
"Bbox center in Y is incorrect!"
)

if abs(msg.center.theta) > 1e-8:
"Bbox theta is not 0.0!"
Expand Down

0 comments on commit 6880306

Please sign in to comment.