Skip to content

Commit

Permalink
Merge pull request #993 from dstl/intervals
Browse files Browse the repository at this point in the history
Add logic to allow CompoundTimeRange to initiate with CompoundTimeRange
  • Loading branch information
sdhiscocks committed Apr 29, 2024
2 parents 990aa7c + a0d737a commit fd0cafd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stonesoup/types/interval.py
Expand Up @@ -175,6 +175,8 @@ def __init__(self, *args, **kwargs):
elif not isinstance(self.intervals, MutableSequence):
if isinstance(self.intervals, (Interval, Tuple)):
self.intervals = [self.intervals]
elif isinstance(self.intervals, Intervals):
self.intervals = self.intervals.intervals
else:
raise TypeError("Must contain Interval types")
elif len(self.intervals) == 2 and all(isinstance(elem, Real) for elem in self.intervals):
Expand Down
7 changes: 7 additions & 0 deletions stonesoup/types/tests/test_time.py
Expand Up @@ -267,3 +267,10 @@ def test_remove(times):
# Remove whole component
test1.remove(TimeRange(times[1], times[2]))
assert test1 == CompoundTimeRange([TimeRange(times[4], times[5])])


def test_compound_time_range_init_with_compound_time_range(times):
time_range = TimeRange(start=times[1], end=times[2])
compound_time_range = CompoundTimeRange(time_range)
compound_time_range_with_compound_time_range = CompoundTimeRange(compound_time_range)
assert compound_time_range.intervals == compound_time_range_with_compound_time_range.intervals

0 comments on commit fd0cafd

Please sign in to comment.