From e3b38b0d512b508ad7ae786ae422180bbb6789b7 Mon Sep 17 00:00:00 2001 From: Kipp Cannon <kipp.cannon@ligo.org> Date: Sat, 24 Nov 2018 19:36:34 +0900 Subject: [PATCH] streamthinca: improve lower_bound_in_seglist() - a thinko was causing it to include one too many segments below the bound than required to satisfy the criterion. it wouldn't lead to incorrect results, just a small slow-down. ligo.segments now provides an implementation of this function, but that version of ligo.segments is not yet in production so we need to retain this implementation here for the time being. --- gstlal-inspiral/python/streamthinca.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gstlal-inspiral/python/streamthinca.py b/gstlal-inspiral/python/streamthinca.py index 534b894dbc..4c0c594128 100644 --- a/gstlal-inspiral/python/streamthinca.py +++ b/gstlal-inspiral/python/streamthinca.py @@ -224,15 +224,10 @@ class last_coincs(object): def lower_bound_in_seglist(seglist, x): - """ - Return the index of the segment immediately at or before x in the - coalesced segment list seglist. Operation is O(log n). - """ - # NOTE: this is an operation that is performed in a number of - # locations in various codes, and is something that I've screwed up - # more than once. maybe this should be put into segments.py itself - i = bisect_right(seglist, x) - return i - 1 if i else 0 + # FIXME: replace with segmentlist.value_slice_to_index() when we + # can rely on a new-enough ligo.segments + i = max(bisect_left(seglist, x) - 1, 0) + return i + 1 if seglist and seglist[i][1] <= x else i class backgroundcollector(object): -- GitLab