I have some code that works with intervals, which are really just python dicts with the following structure:
{
"name": "some utf8 string",
"start": 0.0, # 0.0 <= start < 1.0
"end": 1.0, # start < end <= 1.0
"size": 1.0, # size == end - start
}
Writing a strategy for a single interval is relatively straightforward. I'd like to write a strategy to generate interval sets. An interval set is a list of intervals, such that:
- The list contains an arbitrary number of intervals.
- The interval names are unique.
- The intervals do not overlap.
- All intervals are contained within the range
(0.0, 1.0)
. - Each interval's
size
is correct. - The intervals do not have to be contiguous and the entire range doesn't need to be covered.
How would you write this strategy?