Skip to content

Commit

Permalink
Move tests to common file
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Jul 20, 2023
1 parent 78e7e5c commit aade1ca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 46 deletions.
45 changes: 0 additions & 45 deletions pytransform3d/test/test_temporal_transform_manager.py

This file was deleted.

42 changes: 41 additions & 1 deletion pytransform3d/test/test_transform_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from pytransform3d.transformations import (
random_transform, invert_transform, concat, transform_from_pq,
transform_from)
from pytransform3d.transform_manager import TransformManager
from pytransform3d.transform_manager import (
TransformManager, TemporalTransformManager, StaticTransform)
from pytransform3d import transform_manager
from numpy.testing import assert_array_almost_equal
import pytest
Expand Down Expand Up @@ -335,3 +336,42 @@ def test_remove_and_add_connection():
measurement2 = tm.get_transform("a", "e")

assert_array_almost_equal(measurement1, measurement2)


def test_temporal_transform():
rng = np.random.default_rng(0)
A2B = random_transform(rng)

rng = np.random.default_rng(42)
A2C = random_transform(rng)

tm = TemporalTransformManager()

tm.add_transform("A", "B", StaticTransform(A2B))
tm.add_transform("A", "C", StaticTransform(A2C))

tm.current_time = 1234.0
B2C = tm.get_transform("B", "C")

C2B = tm.get_transform("C", "B")
B2C_2 = invert_transform(C2B)
assert_array_almost_equal(B2C, B2C_2)

B2C_3 = tm.get_transform_at_time("B", "C", 1234.0)
assert_array_almost_equal(B2C_2, B2C_3)


def test_internals():
rng = np.random.default_rng(0)
A2B = random_transform(rng)

rng = np.random.default_rng(42)
A2C = random_transform(rng)

tm = TemporalTransformManager()

tm.add_transform("A", "B", StaticTransform(A2B))
tm.add_transform("A", "C", StaticTransform(A2C))

tm.remove_transform("A", "C")
assert ("A", "C") not in tm.transforms

0 comments on commit aade1ca

Please sign in to comment.