Skip to content
Snippets Groups Projects
Commit e3b38b0d authored by Kipp Cannon's avatar Kipp Cannon
Browse files

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.
parent a4f455ef
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment