diff --git a/src/iranges/IRanges.py b/src/iranges/IRanges.py index be52f29..1ce3383 100644 --- a/src/iranges/IRanges.py +++ b/src/iranges/IRanges.py @@ -1037,7 +1037,11 @@ def gaps(self, start: Optional[int] = None, end: Optional[int] = None) -> "IRang gapwidth = end - max_end out_ranges.append((gapstart, gapwidth)) - _gapstarts, _gapends = zip(*out_ranges) + _gapstarts = [] + _gapends = [] + if len(out_ranges): + _gapstarts, _gapends = zip(*out_ranges) + return IRanges(_gapstarts, _gapends) # folows the same logic as in https://stackoverflow.com/questions/55480499/split-set-of-intervals-into-minimal-set-of-disjoint-intervals