Closed kimlaberinto closed 1 year ago
In the above example, one might find the above unexpected as they would've thought that the function would return
[TimeSpan(3, 6), TimeSpan(8, 10)]
instead.
I know I certainly would have thought that. This seems like a bug to me.
Ah, it's because of this line: https://github.com/beacon-biosignals/TimeSpans.jl/blob/main/src/TimeSpans.jl#L378
Rather than proper containment within the parent span, we should check for overlap with the parent span.
BIG yikes---and good find/mwe!!
Semi-unexpected. I would've thought that inverting on collections that contained "straddling timespans" (i.e. spans where one end is in the
parent_span
and where one end is not inparent_span
) would still result in gaps that do not overlap with any TimeSpan in the input collection. Better explained with example: e.g.In the above example, one might find the above unexpected as they would've thought that the function would return
[TimeSpan(3, 6), TimeSpan(8, 10)]
instead. Another reason why the above is unexpected is because thatinvert_spans
can handle timespans are that completely outside theparent_span
, so one might think that it can also handle straddling timespans.Alternatively though: The other perspective is maybe
invert_spans
isn't even meant to work on straddling timespans or timespans outside the inputparent_span
.I originally ran into this by hitting an error when running on a 1-element collection whose sole timespan is a straddling timespan (or even completely outside).
IMO to address this issue, we'll have to determine what behaviour we want TimeSpans.jl to do in these cases