From 8c01d3200cf7271d3d0a302e159d7e7340359475 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Wed, 19 Jun 2024 21:49:04 -0700 Subject: [PATCH] Fix bug in gaps before unzipping results (#35) --- src/iranges/IRanges.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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