Skip to content

Commit 468cfcc

Browse files
authored
Merge pull request #623 from dstl/deleter_fixes
Fix time steps based deleter Fixes #610
2 parents 8066e8b + 4b38419 commit 468cfcc

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

stonesoup/deleter/time.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ def check_for_deletion(self, track, **kwargs):
2727
Returns
2828
-------
2929
bool
30-
`True` if track has an :class:`~.Update` with measurements within
31-
time steps; `False` otherwise.
30+
`False` if track has an :class:`~.Update` with measurements within
31+
time steps; `True` otherwise.
3232
"""
33-
return not any(isinstance(state, Update) and state.hypothesis
34-
for state in track[-self.time_steps_since_update:])
33+
timestamps_set = set()
34+
35+
for state in track[::-1]:
36+
timestamps_set.add(state.timestamp)
37+
if len(timestamps_set) > self.time_steps_since_update:
38+
return True
39+
40+
if isinstance(state, Update) and state.hypothesis:
41+
return False
42+
43+
return False
3544

3645

3746
class UpdateTimeDeleter(Deleter):
@@ -57,8 +66,8 @@ def check_for_deletion(self, track, timestamp=None, **kwargs):
5766
Returns
5867
-------
5968
bool
60-
`True` if track has an :class:`~.Update` with measurements within
61-
time; `False` otherwise.
69+
`False` if track has an :class:`~.Update` with measurements within
70+
time; `True` otherwise.
6271
"""
6372
if timestamp is None:
6473
timestamp = track.timestamp

0 commit comments

Comments
 (0)