There will a brief, around 15 minute, outage of git.ligo.org, chat.ligo.org, and docs.ligo.org tomorrow evening, Tuesday 15 October 2019, at 10pm CDT. This is due to some campus level network maintenance work that is being carried out.

Commit b8e57142 authored by Kipp Cannon's avatar Kipp Cannon

use __all__ to control exported symbols

parent 88e76ec2
......@@ -42,15 +42,25 @@ glue.segmentsUtils
"""
from bisect import bisect_left as _bisect_left
from bisect import bisect_right as _bisect_right
from copy import copy as _shallowcopy
from bisect import bisect_left
from bisect import bisect_right
from copy import copy as shallowcopy
__author__ = "Kipp Cannon <kipp.cannon@ligo.org>"
__version__ = '1.0.0'
__all__ = [
"infinity",
"PosInfinity",
"NegInfinity",
"segment",
"segmentlist",
"segmentlistdict"
]
#
# =============================================================================
#
......@@ -550,7 +560,7 @@ class segmentlist(list):
"""
if isinstance(item, self.__class__):
return all(seg in self for seg in item)
i = _bisect_left(self, item)
i = bisect_left(self, item)
return ((i != 0) and (item in self[i-1])) or ((i != len(self)) and (item in self[i]))
# supplementary accessors
......@@ -624,7 +634,7 @@ class segmentlist(list):
return self
i = 0
for seg in other:
i = j = _bisect_right(self, seg, i)
i = j = bisect_right(self, seg, i)
lo, hi = seg
if i and self[i - 1][1] >= lo:
i -= 1
......@@ -736,7 +746,7 @@ class segmentlist(list):
other is not the null set, otherwise returns False. The
algorithm is O(log n). Requires the list to be coalesced.
"""
i = _bisect_left(self, other)
i = bisect_left(self, other)
return ((i != 0) and (other[0] < self[i-1][1])) or ((i != len(self)) and (other[1] > self[i][0]))
def intersects(self, other):
......@@ -986,7 +996,7 @@ class segmentlistdict(dict):
keys = self
new = self.__class__()
for key in keys:
new[key] = _shallowcopy(self[key])
new[key] = shallowcopy(self[key])
dict.__setitem__(new.offsets, key, self.offsets[key])
return new
......@@ -1096,7 +1106,7 @@ class segmentlistdict(dict):
if key in self:
self[key] |= value
else:
self[key] = _shallowcopy(value)
self[key] = shallowcopy(value)
return self
def __or__(self, other):
......@@ -1121,7 +1131,7 @@ class segmentlistdict(dict):
if key in self:
self[key] ^= value
else:
self[key] = _shallowcopy(value)
self[key] = shallowcopy(value)
return self
def __xor__(self, other):
......@@ -1201,7 +1211,7 @@ class segmentlistdict(dict):
"""
for key, value in other.items():
if key not in self:
self[key] = _shallowcopy(value)
self[key] = shallowcopy(value)
else:
self[key].extend(value)
......@@ -1240,7 +1250,7 @@ class segmentlistdict(dict):
new = self.__class__()
intersection = self.intersection(keys)
for key in keys:
dict.__setitem__(new, key, _shallowcopy(intersection))
dict.__setitem__(new, key, shallowcopy(intersection))
dict.__setitem__(new.offsets, key, self.offsets[key])
return new
......@@ -1281,7 +1291,7 @@ class segmentlistdict(dict):
keys = set(keys)
if not keys:
return segmentlist()
seglist = _shallowcopy(self[keys.pop()])
seglist = shallowcopy(self[keys.pop()])
for key in keys:
seglist &= self[key]
return seglist
......@@ -1294,7 +1304,7 @@ class segmentlistdict(dict):
keys = set(keys)
if not keys:
return segmentlist()
seglist = _shallowcopy(self[keys.pop()])
seglist = shallowcopy(self[keys.pop()])
for key in keys:
seglist |= self[key]
return seglist
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment