|
3 | 3 |
|
4 | 4 | from ...types.state import GaussianState |
5 | 5 | from ...types.track import Track |
6 | | -from ..track import Tracks2GaussianDetectionFeeder |
| 6 | +from ..track import Tracks2GaussianDetectionFeeder, ReplayTrackFeeder |
7 | 7 |
|
8 | 8 | t1 = Track(GaussianState([1, 1, 1, 1], np.diag([2, 2, 2, 2]), timestamp=2)) |
9 | 9 | t2 = Track([GaussianState([1, 1, 1, 1], np.diag([2, 2, 2, 2]), timestamp=1), |
|
13 | 13 | GaussianState([3, 1], np.diag([2, 2]), timestamp=2)]) |
14 | 14 | t4 = Track(GaussianState([1, 0, 1, 0, 1, 0], np.diag([2, 2, 2, 2, 2, 2]), timestamp=2)) |
15 | 15 |
|
| 16 | +times = [0, 1, 2] |
| 17 | + |
16 | 18 |
|
17 | 19 | @pytest.mark.parametrize( |
18 | 20 | "tracks", |
@@ -53,3 +55,23 @@ def test_Track2GaussianDetectionFeeder(tracks): |
53 | 55 | if detection.metadata['track_id'] == track.id)) |
54 | 56 | assert np.all(detection.state_vector == track.state_vector) |
55 | 57 | assert np.all(detection.covar == track.covar) |
| 58 | + |
| 59 | + |
| 60 | +@pytest.mark.parametrize(("tracks", "times"), |
| 61 | + [([t1], times), ([t1], None), |
| 62 | + ([t1, t2], times), ([t1, t2], None), |
| 63 | + ([t2, t3], times), ([t2, t3], None), |
| 64 | + ([t1, t2, t3, t4], times), ([t1, t2, t3, t4], None)]) |
| 65 | +def test_ReplayTrackFeeder(tracks, times): |
| 66 | + feeder = ReplayTrackFeeder(reader=tracks, times=times) |
| 67 | + feeder_times = [] |
| 68 | + feeder_tracks = set() |
| 69 | + for new_time, new_tracks in feeder: |
| 70 | + print(new_time, new_tracks) |
| 71 | + feeder_times.append(new_time) |
| 72 | + feeder_tracks |= new_tracks |
| 73 | + if times is not None: |
| 74 | + assert times == feeder_times |
| 75 | + assert len(tracks) == len(feeder_tracks) |
| 76 | + assert (sorted([len(track) for track in tracks]) == |
| 77 | + sorted([len(track) for track in feeder_tracks])) |
0 commit comments